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
[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