📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 59

2021-05-27 •Youtube

Detailed Notes

We wrap up our season with some free options for hosting your Django application.

AWS: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

OpenShift: https://docs.openshift.com/container-platform/3.4/dev_guide/migrating_applications/quickstart_examples.html

PythonAnywhere: https://www.pythonanywhere.com/pricing/

Heroku: https://devcenter.heroku.com/articles/getting-started-with-python

mod_wsgi: https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/modwsgi/

You can view source for today and all prior days by reviewing the code at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
hello and welcome back
we are i guess i'm apologizing here
we're gonna we're gonna bail out a
little bit on
the deploying django and production
and the the issue with that is that as i
started working through it
there are uh if you do it manually there
are a lot of
pieces to get into place uh potent uh i
guess i'll sort of cover it briefly
is what i was gonna do was dealt with um
deploying it on apache too uh version
2.0
and the thing about apache 2.0
and this thing called mod wsgi
which if you want to do it it has a
pretty good uh you can go actually
out to the django documentation you can
find a pretty good walk through
and also out on the apache site it talks
about how to
uh install it and get it turned on
but there are a lot of little version
gotchas that you can run into it's very
important to be sure whether you're
dealing with
version apache 2.2 or 2.4
and the python version can
somewhat come into play as well and
there are a lot of like sometimes
happens when you start messing around
with
any modification to out-of-the-box web
stuff
depending on what your web server is you
can run into some permissions issues and
things like that
so rather than go through a lot of time
talking about configuration and things
like that
i figured i'd actually shortcut a little
bit and move us on to some more
you know python and django related stuff
which will be essentially wrapping up
this series
and i'm going to get into more specific
stuff focused on
python and whether you want to get if
you want to get a certification
in python we're going to actually walk
through the
essentially the syllabus and learning
the items related to that
so for now i wanted to point out that
there is this mod wsjwsg
that you can you can install on your
server
it varies depending on what your server
is what your server operating system is
but there are some walks some plenty of
tutorials to do it
much like the other things i'm going to
talk about i highly recommend
when you install it take the easiest
most simple
hello world version of setting it up
first
walk through that and then start putting
your
application files into it if you try to
do it all at once
it's it's much more complicated now
if i haven't scared you away yet there
are
shortcuts there are easier ways to deal
with this
i'm going to talk about four of them now
one we
may have briefly touched on early on is
that aws
has a way to build out
a django environment if you go into
their systems if you go
use ecs there are ways that they will
pre-build stuff for you
and again what you can do is go through
build the
the most simple version and then add
your files
into it and there's uh there's pipelines
and things like that that are related to
that so that you can actually
tie it into your version control and get
all that stuff
automated and spin up a server that's
going to be probably easier
than building something from scratch
now there are some gotchas there you're
going to have to make sure that you have
been
updating the requirements text file
along the way
which basically tells any pipeline what
libraries need to be loaded in as it's
building out its system
so aws has a pretty good system that you
can use uh one that's actually
really nice that i've used in the past
actually early on
when i was working with django is heroku
and they have uh if you go out there
they've got a free
you can do free hosting for your django
app
and they have actually a pretty good
walk through
if you go in and look for deploying
python and django apps and i think if
you just google django and heroku
then you'll see they've got a getting
started on heroku with python
and they'll talk about you know they'll
walk you through getting heroku set up
and then getting python and then
working with django and getting that set
up
and there's a lot of good documentation
there to build out your
your application depending on how you
want to want to do so
in a similar vein there is a red hat's
open shift
they've got very much like heroku they
are a
a cloud container system and they do
have
some good examples they actually have
django with a postgres database instead
of
mysql and that was one that i've walked
through at
some point and from what i remember it's
been a while but it was also a very good
example and what you see with a lot of
these is they actually have source codes
so you have a
like essentially a template to get
started with so you can
usually within literally minutes you can
pull that down
and have a hello world running out on
their cloud
and then you can start customizing it
out
and that yeah you have to be a little
bit careful because you you don't want
to just like step on setting files and
things like that
but you should be able to move fairly
quickly to get those pieces set up
and there is documentation if you want
to depending on your database style
most of them are going to want to do the
sql lite that's default
but there are ways to either in some
cases spin up a mysql database
or the other thing you do is you can
just point to your mysql database
and just make sure that the cloud server
you create
has the appropriate permissions to be
able to actually hit your
you know a separate database server
where your database lives
so you've got heroku aws you've got open
shift another one that uh you know by
its name python anywhere
you can jump out there it is a little
bit different because
if you look at the price although you
can get a free heroku free
open shift and there is free tier
stuff available in aws python anywhere
really if you're going to do something
that's going to be an actual any sort of
production
type like you know even if it's just a
few users you're probably gonna have to
go to their twelve dollar
i'm sorry their five dollar a month um
subscription plan
which is going to be enough to run your
application you can play around with it
you can
you know do what you need to
particularly if it's for personal or
family use or something where
it's not a huge number of users
then you can you can run through that
now all of these like i said they do
have examples
they do have tutorials and i would
i highly recommend that you walk through
the tutorial
as verbatim as possible and then
migrate your your files over and this
may even be that you create a whole
different
git repository and assuming you've been
using git along the way
but you use an entirely new git
repository
and start putting your files into that
and then deploy
as you go it can be
and it's just sort of heads up which is
why we've bailed out a little bit on how
i was working with this for this
uh this series of videos it can be
somewhat daunting
there are a lot of moving parts
much like anything if you've dealt with
any kind of container
situations where you're building
applications or docker
uh kubernetes all these kinds of
pipelines
all of these great technologies do
require
that you configure them properly they're
incredibly powerful but
you need to make sure that you cross all
your t's and dotted
your eyes so that all the right
libraries get created properly
they do you know the upside is they do
tend to have really
good logging i have run into all kinds
of situations over the years of issues
that have come up
deploying all of these different types
of apps
and across the board they have really
good logs
so take a look at the logs look at
whatever errors come up
and then you know move forward from
there
if you want to keep it simple you can
always just you know use your
uh your django server that you're using
i would turn off
the uh the development mode so it's not
kicking out so much information
uh make sure that you've got your files
protected in a way so that you don't
have
usernames and passwords that are visible
to the outside world
and then you can run it that way it's
not necessarily the
the fastest or best solution but again
if this is personal use or small number
of users or something like that
then you know don't don't get caught up
in the configuration side
of python and django instead just get
your application out there start using
it
and then you know advance it as you need
to and enhance it and
do the things that are you know that
makes sense
for you to turn it into something that
you really want to that you you're proud
of that you use on a daily basis
or you know at least a regular basis
because that's
you know at the end of the day for some
of the stuff that's sort of the purpose
is let's
let's build something that solves the
problem and
that means every time you face that
problem ideally
that application is the solution that
you turn to
so i will in the show notes um i will
put links to
uh heroku and quickstart uh actually i'm
probably look
to the documentation for each of these
so the quick start for
openshift the heroku django tutorial
the uh just python anywhere i'll put a
link out to there and then
aws um i'm not sure what they've got
i've got to go back and look because
usually i just walk through it using
they've got a wizard if you go through
there to create out that environment
and you can sort of run from there
so that being said i think it's a good
time to wrap this one up
uh thank you for for your time for
walking through all of these tutorials
i apologize if i implied that we're
going to get more
of the production side of stuff done
than than we have
i apologize for punting a little on that
but it was just one of those i just
i didn't want to get i didn't want to
muddy the waters with too many
configuration related
uh items and and issues and uh
you know just the tdm uploading those
libraries and making sure all of them
are in place
i am going to basically right away turn
around although we've got a couple of
other videos that we're showing in our
in our regular release schedule on
tuesdays and thursdays
i am very quickly going to turn around
and have been actually itching to turn
around
and dive into another the next python
series which will be
focused on getting a python
certification
i have not gone all the way through that
as far as what's on the syllabus
i'm not sure how much uh if any django
will be involved it's definitely going
to be heavily python
so there will be a little bit of
repetition probably we will go back over
things that we've covered
in this series but it's it's things that
we're going to do it as
best possible in a way that matches what
the the certification process is looking
for
and the kind of knowledge items that
they that they're going to talk about
and that you're going to see assuming
you go for in the test
and that goal being that we'll go
through that and be able to take a
certification
and pass it and you know have be a
certified python developer as well as
just
really be by then i'm guessing really
comfortable
with the python world so that's coming
up next
as always thank you for your time
through all of this go out there
have yourself a great day a great week
and we will talk to you
next time
you
Transcript Segments
0.62

[Music]

26.24

hello and welcome back

27.84

we are i guess i'm apologizing here

30.72

we're gonna we're gonna bail out a

32.16

little bit on

33.2

the deploying django and production

37.2

and the the issue with that is that as i

40.399

started working through it

42.16

there are uh if you do it manually there

44.96

are a lot of

46.32

pieces to get into place uh potent uh i

49.36

guess i'll sort of cover it briefly

51.039

is what i was gonna do was dealt with um

54.48

deploying it on apache too uh version

58.48

2.0

59.68

and the thing about apache 2.0

63.28

and this thing called mod wsgi

67.36

which if you want to do it it has a

68.88

pretty good uh you can go actually

70.96

out to the django documentation you can

73.36

find a pretty good walk through

74.56

and also out on the apache site it talks

77.04

about how to

78.56

uh install it and get it turned on

82

but there are a lot of little version

85.119

gotchas that you can run into it's very

88.4

important to be sure whether you're

89.68

dealing with

91.04

version apache 2.2 or 2.4

96.799

and the python version can

100.079

somewhat come into play as well and

103.92

there are a lot of like sometimes

106.64

happens when you start messing around

108.079

with

108.96

any modification to out-of-the-box web

111.84

stuff

112.96

depending on what your web server is you

115.119

can run into some permissions issues and

116.799

things like that

118.24

so rather than go through a lot of time

122

talking about configuration and things

123.84

like that

125.36

i figured i'd actually shortcut a little

127.2

bit and move us on to some more

129.759

you know python and django related stuff

132.08

which will be essentially wrapping up

133.52

this series

134.56

and i'm going to get into more specific

136.4

stuff focused on

138.08

python and whether you want to get if

139.76

you want to get a certification

141.52

in python we're going to actually walk

143.12

through the

144.64

essentially the syllabus and learning

146.56

the items related to that

149.599

so for now i wanted to point out that

151.76

there is this mod wsjwsg

157.36

that you can you can install on your

159.36

server

160.48

it varies depending on what your server

162.72

is what your server operating system is

165.2

but there are some walks some plenty of

167.28

tutorials to do it

169.599

much like the other things i'm going to

170.72

talk about i highly recommend

173.12

when you install it take the easiest

176.08

most simple

177.36

hello world version of setting it up

179.28

first

181.04

walk through that and then start putting

184.08

your

185.04

application files into it if you try to

188

do it all at once

188.959

it's it's much more complicated now

192.64

if i haven't scared you away yet there

195.12

are

196

shortcuts there are easier ways to deal

197.519

with this

199.2

i'm going to talk about four of them now

201.76

one we

203.2

may have briefly touched on early on is

205.68

that aws

206.959

has a way to build out

210.799

a django environment if you go into

213.68

their systems if you go

214.879

use ecs there are ways that they will

217.04

pre-build stuff for you

219.2

and again what you can do is go through

221.599

build the

222.319

the most simple version and then add

225.2

your files

225.92

into it and there's uh there's pipelines

228.48

and things like that that are related to

230.159

that so that you can actually

232.08

tie it into your version control and get

234.48

all that stuff

235.2

automated and spin up a server that's

238.4

going to be probably easier

240.239

than building something from scratch

243.36

now there are some gotchas there you're

245.04

going to have to make sure that you have

246.4

been

246.799

updating the requirements text file

249.36

along the way

250.64

which basically tells any pipeline what

254.08

libraries need to be loaded in as it's

256.32

building out its system

258.639

so aws has a pretty good system that you

261.199

can use uh one that's actually

263.44

really nice that i've used in the past

265.52

actually early on

266.8

when i was working with django is heroku

269.919

and they have uh if you go out there

272.479

they've got a free

273.36

you can do free hosting for your django

276.639

app

277.52

and they have actually a pretty good

279.84

walk through

280.8

if you go in and look for deploying

283.919

python and django apps and i think if

285.759

you just google django and heroku

288.24

then you'll see they've got a getting

289.84

started on heroku with python

292.08

and they'll talk about you know they'll

293.84

walk you through getting heroku set up

295.919

and then getting python and then

297.44

working with django and getting that set

299.68

up

300.72

and there's a lot of good documentation

302.56

there to build out your

305.12

your application depending on how you

306.88

want to want to do so

309.12

in a similar vein there is a red hat's

312.08

open shift

313.759

they've got very much like heroku they

315.919

are a

317.12

a cloud container system and they do

319.52

have

320.32

some good examples they actually have

321.759

django with a postgres database instead

323.919

of

324.479

mysql and that was one that i've walked

327.44

through at

327.919

some point and from what i remember it's

330.88

been a while but it was also a very good

333.6

example and what you see with a lot of

336.08

these is they actually have source codes

337.919

so you have a

339.6

like essentially a template to get

341.199

started with so you can

343.199

usually within literally minutes you can

345.759

pull that down

346.8

and have a hello world running out on

348.8

their cloud

349.84

and then you can start customizing it

352.479

out

353.039

and that yeah you have to be a little

354.72

bit careful because you you don't want

356.319

to just like step on setting files and

358.16

things like that

358.96

but you should be able to move fairly

361.039

quickly to get those pieces set up

363.52

and there is documentation if you want

365.36

to depending on your database style

367.52

most of them are going to want to do the

370.319

sql lite that's default

373.039

but there are ways to either in some

375.68

cases spin up a mysql database

378.08

or the other thing you do is you can

379.68

just point to your mysql database

382.24

and just make sure that the cloud server

384.56

you create

385.44

has the appropriate permissions to be

387.199

able to actually hit your

388.8

you know a separate database server

390.639

where your database lives

393.759

so you've got heroku aws you've got open

396.639

shift another one that uh you know by

398.479

its name python anywhere

400.4

you can jump out there it is a little

402.8

bit different because

404.319

if you look at the price although you

406

can get a free heroku free

408.88

open shift and there is free tier

412.639

stuff available in aws python anywhere

416.16

really if you're going to do something

418.4

that's going to be an actual any sort of

420.88

production

421.52

type like you know even if it's just a

423.039

few users you're probably gonna have to

424.639

go to their twelve dollar

425.759

i'm sorry their five dollar a month um

428.24

subscription plan

429.759

which is going to be enough to run your

431.039

application you can play around with it

432.72

you can

433.36

you know do what you need to

434.72

particularly if it's for personal or

436.639

family use or something where

438.16

it's not a huge number of users

441.599

then you can you can run through that

447.28

now all of these like i said they do

449.84

have examples

451.039

they do have tutorials and i would

454.08

i highly recommend that you walk through

456.639

the tutorial

457.44

as verbatim as possible and then

461.759

migrate your your files over and this

464.24

may even be that you create a whole

465.84

different

466.8

git repository and assuming you've been

468.96

using git along the way

471.12

but you use an entirely new git

473.599

repository

474.8

and start putting your files into that

477.039

and then deploy

478.16

as you go it can be

483.039

and it's just sort of heads up which is

484.96

why we've bailed out a little bit on how

486.4

i was working with this for this

488.08

uh this series of videos it can be

490.639

somewhat daunting

492.16

there are a lot of moving parts

495.599

much like anything if you've dealt with

497.28

any kind of container

498.8

situations where you're building

500.08

applications or docker

502.08

uh kubernetes all these kinds of

503.919

pipelines

505.199

all of these great technologies do

508.319

require

509.12

that you configure them properly they're

511.12

incredibly powerful but

513.68

you need to make sure that you cross all

515.919

your t's and dotted

516.959

your eyes so that all the right

518.479

libraries get created properly

521.12

they do you know the upside is they do

523.039

tend to have really

524.32

good logging i have run into all kinds

527.12

of situations over the years of issues

529.519

that have come up

530.32

deploying all of these different types

532

of apps

533.44

and across the board they have really

536.56

good logs

537.44

so take a look at the logs look at

539.12

whatever errors come up

541.04

and then you know move forward from

542.72

there

544.64

if you want to keep it simple you can

547.04

always just you know use your

549.44

uh your django server that you're using

551.279

i would turn off

552.48

the uh the development mode so it's not

555.12

kicking out so much information

557.6

uh make sure that you've got your files

559.2

protected in a way so that you don't

560.64

have

561.6

usernames and passwords that are visible

564.399

to the outside world

566.24

and then you can run it that way it's

568.399

not necessarily the

570.48

the fastest or best solution but again

574.399

if this is personal use or small number

577.2

of users or something like that

578.72

then you know don't don't get caught up

582.08

in the configuration side

583.76

of python and django instead just get

586.48

your application out there start using

588

it

588.64

and then you know advance it as you need

590.959

to and enhance it and

592.24

do the things that are you know that

594.24

makes sense

595.6

for you to turn it into something that

597.279

you really want to that you you're proud

599.279

of that you use on a daily basis

601.519

or you know at least a regular basis

604.24

because that's

605.12

you know at the end of the day for some

606.399

of the stuff that's sort of the purpose

607.76

is let's

608.56

let's build something that solves the

609.839

problem and

611.68

that means every time you face that

613.04

problem ideally

614.72

that application is the solution that

616.32

you turn to

618.24

so i will in the show notes um i will

620.72

put links to

622.64

uh heroku and quickstart uh actually i'm

625.519

probably look

626.079

to the documentation for each of these

628.32

so the quick start for

630.56

openshift the heroku django tutorial

634.399

the uh just python anywhere i'll put a

636.32

link out to there and then

638.16

aws um i'm not sure what they've got

642

i've got to go back and look because

642.959

usually i just walk through it using

644.56

they've got a wizard if you go through

646.16

there to create out that environment

649.12

and you can sort of run from there

653.2

so that being said i think it's a good

655.519

time to wrap this one up

657.04

uh thank you for for your time for

659.04

walking through all of these tutorials

661.12

i apologize if i implied that we're

663.519

going to get more

664.64

of the production side of stuff done

666.64

than than we have

668.24

i apologize for punting a little on that

670

but it was just one of those i just

671.36

i didn't want to get i didn't want to

673.12

muddy the waters with too many

674.32

configuration related

675.839

uh items and and issues and uh

678.959

you know just the tdm uploading those

680.64

libraries and making sure all of them

682.16

are in place

684.079

i am going to basically right away turn

686.32

around although we've got a couple of

688

other videos that we're showing in our

689.68

in our regular release schedule on

691.36

tuesdays and thursdays

692.88

i am very quickly going to turn around

694.48

and have been actually itching to turn

696

around

696.72

and dive into another the next python

699.6

series which will be

700.64

focused on getting a python

702.56

certification

703.839

i have not gone all the way through that

705.92

as far as what's on the syllabus

708.56

i'm not sure how much uh if any django

711.92

will be involved it's definitely going

714.079

to be heavily python

716.079

so there will be a little bit of

718.56

repetition probably we will go back over

720.639

things that we've covered

721.76

in this series but it's it's things that

724.48

we're going to do it as

725.519

best possible in a way that matches what

728.959

the the certification process is looking

731.44

for

732.16

and the kind of knowledge items that

733.76

they that they're going to talk about

736.32

and that you're going to see assuming

738.32

you go for in the test

739.36

and that goal being that we'll go

741.2

through that and be able to take a

742.32

certification

743.12

and pass it and you know have be a

746.079

certified python developer as well as

748.079

just

748.48

really be by then i'm guessing really

750.88

comfortable

752.079

with the python world so that's coming

754

up next

755.12

as always thank you for your time

756.32

through all of this go out there

758.56

have yourself a great day a great week

760.959

and we will talk to you

762.639

next time

781.68

you