Detailed Notes
We wrap up our UAT fixes and start to look at gathering source and data for our move to production in the next episode.
You can view source for today and all prior days by reviewing the tag Day 57 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial
Transcript Text
[Music] three two one well hello and back welcome back we are down to one task uh if we go here oops we have one left from our little uat and we're gonna deal with time frame and deleting it so now it's been a while so let's go back to that within this one let's create a time frame and this one's going to be just where it's at so this will be parent delete me and i want to save a record and then i'm going to create a child time frame which is going to be a child delete me [Music] and so i should be able from there now this is interesting is i can't from here go back to my parent oh child delete me should be parents should be i'm sorry i should do that okay so now if i go back to my road maps go here parent delete me has one child has one child and so now what i want to do is make sure that when i delete the parent it's going to delete the child and let's see what happens if i delete it now child delete me is going to show up it gets moved up which may have been what i decided to do oh so now it just it takes the children and moves it up so i may be actually good with this and so a child delete me has two zero children if i delete that record then i'm good so actually i think we covered what we needed to we may fix this in a prior one and now if we go to immediate we have only this task which is now complete and boom we are done so now that takes us to the uh the next step which is going to be deploying our application and when we want to move this over there's really there's a couple things we need to do this episode i want to just uh with the little time we have in this one i want to go ahead and talk about the files we're going to move and then we'll actually talk about setting up a production django server in our last episode because there are some tricks to it as we currently see we've got this thing while this is mapped out pretty nicely normally when you're running django particularly if you look in our settings we're gonna see that there's some things that you're not supposed to do and where is it at uh there it is some things you're not supposed to do in production for example security warning if this was a key for production then we're going to have to keep that secret uh and that's used for a couple different things for security purposes you may have noted that here while we are https right now uh typically you're not going to have that from the default and so there's a couple of things we want to do as well django typically is not going to be your front end it's going to be your friend and web server you're going to have it fronted by you know maybe like a nginx or something like that or more commonly apache which is what we're going to show in that episode but first now we have talked about in the database side that we can take these things and we have our migrations that we can use to build our database from scratch so if we wanted to we could come in and completely recreate our database using our migrations we're not going to do that this time what we want to do is we're going to go in and we're going to do what's called mysql dump and we're just going to take our database and we're going to move the whole thing over the way you do that is you're going to give it a u which i think is going to go back to my settings always forget my database user's root password is developer newer for this particular one and so all i need to do is i'm going to take my database what's the name of my database is tp project [Music] and i'm going to do it to dproject dot sql so i'm going to do is take my entire database and i'm going to dump it out to a sql file that would allow me to recreate so i do that and now if i look let's go look at that real quick if i look at that sql file i'm going to see that's got a whole bunch of stuff and that's going to come into each of the tables down here and it's going to see if it exists drop it and then in here we're going to see as we go down let's scroll down a little bit we're going to see here if you look down here we're going to see where it's actually going to insert some records and things like that no it does not actually set a database so what we can do is i'm going to go back into the same i'm going to go in i'm going to use this command line there are other ways you can do it i'll show my databases and if i do use dp project show tables all right so here's a bunch of tables so now what i'm going to do is i'm going to create database uh i'm just going to call it example i'm going to use example use that database and then if i pull in dp dpproject.sql which is in the current directory of where i just ran this then now i'm here i'm going to see that i just created all my tables so if i do select star from oh what did i call it like dp project task i'm going to see a whole bunch of information which is all my tasks so i can see here like set task background color based on status and i can see the information so i just completely re copied replicated my database now let me do drop database example and quit out so what i have now is i have my little sql file that is my database now the files themselves there's a couple different ways we can do it from our purpose what we want to do is we've been using get all along that's git and i think if we go out here if we go out to our github account and see where we've got let's see here and we can actually clone so if i take that link and i can just copy it i could jump on a new server and let's just say we're going to do a new directory so i'm just going to do make dir temp make dr temp cd temp and then do a git clone that and then i'm going to see that i have my project i can go in here and i could actually if i wanted to run it i don't think let me kill this one because i don't think it's going to like having two and let's let's just get down here and let's just run it oop that's not the manager's not there i gotta jump up one more pro level now run it and boom now i'm running my i'm running my application again so it's actually fairly easy for what we've got because we've been using github all along because we've got our database set up in such a way that we can easily dump it and and restore it then we're going to be in a simple situation of being able to replicate this somewhere else and this assuming we're going to move to a production server and we'll take a look at that this next time around we'll actually go set this up on a production server i'm going to get a i'll connect to a different server so we'll be able to actually see some stuff out there but what we're going to do is and we will just all we're going to have to do is depending on how you copy it you can either do a scp so i could do first let's get rid of temp and then if i go out to my whoops oh environment there we go and so i've got my so i could just do scp dpproject.sql2 you know my username at some number or some ip address or something like that and a home switch my username and if i do that then it's going to copy that file out this won't because it's going to say that doesn't exist and i'm going to do the same and actually i'm just going to do a git clone on the other side and be able to pull all of my uh files down and of course that does you know assume that we've been committing along the way now typically i think we sort of skipped over a little bit but all you have to do is really if you do a get dash add dot it's going to add all your changes i'm sorry god oh one second i can i reverse those two it's a get ad there we go so if i do a get add dot i'm going to see if there's anything here i can do a git commit and i'm going to give it a comment of some sort and it's going to commit stuff and i can do that right now because i don't want to commit my sql file and then we can tag it and you will see much as we have here then you'll be able to come in here and you can clone it out and you can see where we've got uh somewhere in here code i think i've got oh here's my tags um i can probably see commit somewhere i forget where i get to see all my commit history but i can see this tag i can pull this it'll i can actually pull the zip file or uh tart and gzipped file if i wanted let's see so let's go back to our code and i can see i've got some branches and yeah that's enough for there that's enough for the kit up hub stuff that stuff you can pretty much play around with and we are going to clone that out now the tricky part is going to be our static files and where is that because this currently is being served if we look in our settings it's currently being served from a slash static but what we could end up doing is we could actually which we're going to show ourselves next time as i can go out to http colon backslash let's say mysite.com static and i can shove all these files there and it's going to pick them up and that's going to be our where our apache front end is going to pick those files up so we've got a couple things we've got to configure and i want to make sure that we sort of mention those uh before we get too far into this and that's going to be our that's going to be our last episode we're not going to worry about this one is we're going to come in we're going to have a another place we're going to have a server that we're going to configure well it's going to be configured and we're going to configure our django app on it so just as sort of a heads up if you're wanting to follow this all the way through if you've got a server somewhere then that you're going to deploy to that's going to be your we'll call it your production server make sure that you have git configured make sure you have my sql already installed and make sure that you have apache on there and then we'll walk through those pieces and that'll be our final episode so as always until then have yourself a great day and we will talk to you next time you
Transcript Segments
[Music]
three
two one well hello and back welcome back
we are down to one
task uh if we go here oops we have one
left
from our little uat and we're gonna deal
with time frame
and deleting it so now it's been a while
so let's go back to that
within this one let's create a time
frame and this one's going to be
just where it's at so this will be
parent delete me
and i want to save a record
and then i'm going to create a child
time frame which is going to be a
child delete me
[Music]
and so i should be able from there
now this is interesting is i can't from
here go back to
my parent oh child delete me should be
parents should be i'm sorry i should do
that
okay so now if i go back to my road maps
go here
parent delete me has one child has one
child
and so now what i want to do is make
sure that when i delete
the parent it's going to delete the
child and let's see what happens if i
delete it
now child delete me is going to show up
it gets moved up
which may have been what i decided to do
oh so now it just it takes the children
and moves it up so i may be actually
good with this
and so a child delete me has two zero
children if i delete that record
then i'm good so actually i think we
covered what we needed to we may fix
this
in a prior one and now if we go to
immediate we have
only this task which is now complete
and boom we are done so now that takes
us to
the uh the next step which is going to
be deploying
our application
and when we want to move this over
there's really there's a couple things
we need to do
this episode i want to just uh with the
little time we have in this one
i want to go ahead and talk about the
files we're going to move and then we'll
actually talk about
setting up a production django server in
our last episode
because there are some tricks to it as
we currently see we've got this thing
while this is mapped out pretty nicely
normally
when you're running django particularly
if you look in our
settings we're gonna see
that there's some things that you're not
supposed to do
and where is it at
uh there it is some things you're not
supposed to do in production
for example security warning if this was
a key
for production then we're going to have
to keep that secret
uh and that's used for a couple
different things for security
purposes you may have noted that here
while we are https right now
uh typically you're not going to have
that from the default and so there's a
couple of things we want to do
as well django typically is not going to
be your front end
it's going to be your friend and web
server you're going to have it fronted
by
you know maybe like a nginx or something
like that or
more commonly apache which is what we're
going to show
in that episode but first
now we have talked about in the database
side
that we can take these things and we
have our migrations that we can use to
build our database from scratch
so if we wanted to we could come in and
completely recreate our database using
our migrations
we're not going to do that this time
what we want to do
is we're going to go in and we're going
to do what's called mysql dump
and we're just going to take our
database and we're going to move the
whole thing over
the way you do that is you're going to
give it a
u which i think is going to go back to
my settings always forget my database
user's root password is developer newer
for this particular one
and so all i need to do is i'm going to
take my database what's the name of my
database
is tp project
[Music]
and i'm going to do it to dproject
dot sql so i'm going to do is take my
entire database
and i'm going to dump it out to a sql
file that would allow me to recreate
so i do that and now if i look
let's go look at that real quick if i
look at that
sql file i'm going to see that's got a
whole bunch of stuff
and that's going to come into each of
the tables down here and it's going to
see
if it exists drop it and then in here
we're going to see
as we go down let's scroll down a little
bit we're going to see here
if you look down here we're going to see
where it's actually going to
insert some records and things like that
no it does not
actually set a database
so what we can do
is i'm going to go back into the same
i'm going to go in i'm going to use this
command line there are other ways you
can do it
i'll show my databases
and if i do use dp project
show tables
all right so here's a bunch of tables so
now what i'm going to do is i'm going to
create database
uh i'm just going to call it example
i'm going to use example use that
database and then if i pull
in dp dpproject.sql which is in the
current directory of where i just ran
this
then now i'm here i'm going to see that
i just created all my tables so if i do
select star from
oh what did i call it like dp project
task i'm going to see a whole bunch of
information
which is all my tasks so i can see here
like set task background color based on
status
and i can see the information so i just
completely
re copied replicated my database now let
me do drop database
example and quit out so
what i have now is i have my little
sql file that is my database now the
files themselves
there's a couple different ways we can
do it from our purpose what we want to
do
is we've been using get all along that's
git
and i think if we go
out here if we go out to our github
account
and see where we've got let's see here
and we can actually
clone so
if i take that link and i can just copy
it
i could jump on a new server and let's
just say we're going to do a new
directory so i'm just going to do make
dir
temp make dr temp cd temp
and then do a git clone that
and then i'm going to see that i have my
project
i can go in here and i could actually if
i wanted to
run it i don't think let me kill this
one because i don't think it's going to
like having two
and let's let's just get down here and
let's just run it
oop that's not the manager's not there i
gotta jump up one more pro
level now run it
and boom now i'm running my i'm running
my application again
so it's actually fairly easy for what
we've got because we've been using
github all along because we've got our
database set up in such a way that we
can easily
dump it and and restore it then
we're going to be in a simple situation
of being able to replicate this
somewhere else
and this assuming we're going to move to
a production server
and we'll take a look at that this next
time around we'll actually go set this
up on a production server i'm going to
get a i'll connect to a different server
so we'll be able to actually see some
stuff out there but what we're going to
do is and we will just all we're going
to have to do
is depending on how you copy it you can
either do a scp
so i could do first let's get rid of
temp
and then if i go out to my
whoops
oh environment
there we go and so i've got my
so i could just do scp dpproject.sql2
you know my username
at some number or some ip address or
something like that
and a home switch my username and if i
do that then it's going to copy that
file out this won't because it's going
to say
that doesn't exist and i'm going to do
the same and
actually i'm just going to do a git
clone on the other side
and be able to pull all of my uh files
down
and of course that does you know assume
that we've been committing along the way
now typically i think we sort of skipped
over a little bit
but all you have to do is really if you
do a get
dash add dot it's going to add all your
changes
i'm sorry god
oh one second
i can i reverse those two it's a get ad
there we go so if i do a get add dot i'm
going to see if there's anything here
i can do a git commit and i'm going to
give it a comment of some sort and it's
going to commit stuff and i can do that
right now because i don't want to commit
my sql file
and then we can tag it and you will see
much as we have here then you'll be able
to come in here
and you can clone it out and you can see
where we've got uh
somewhere in here code i think i've got
oh here's my tags
um i can probably see commit somewhere i
forget where i get to see all my commit
history but
i can see this tag i can pull this it'll
i can actually pull the zip file or
uh tart and gzipped file if i wanted
let's see so let's go back to our code
and i can see i've got some branches
and yeah that's enough for there that's
enough for the kit up
hub stuff that stuff you can pretty much
play around with
and we are going to clone that out now
the tricky part is going to be
our static files and
where is that because this currently is
being served
if we look in our settings it's
currently being served from
a slash static but what we could end up
doing
is we could actually which we're going
to show ourselves next time as i can go
out to http colon backslash
let's say mysite.com
static and i can shove all these files
there
and it's going to pick them up and
that's going to be
our where our apache front end
is going to pick those files up so we've
got a couple things we've got to
configure
and i want to make sure that we sort of
mention those uh before we get too far
into this and that's going to be our
that's going to be our last episode
we're not going to worry about this one
is we're going to come in we're going to
have a
another place we're going to have a
server that we're going to configure
well it's going to be configured and
we're going to configure our django app
on it so
just as sort of a heads up if you're
wanting to follow this all the way
through if you've got a server
somewhere then that you're going to
deploy to that's going to be your we'll
call it your production server make sure
that you have git configured
make sure you have my sql already
installed and make sure that you have
apache on there and then we'll walk
through those pieces
and that'll be our final episode so
as always until then have yourself a
great day and we will talk to you
next time
you