📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 57

2021-05-13 •Youtube

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
0.62

[Music]

27.519

three

28.56

two one well hello and back welcome back

32.64

we are down to one

35.68

task uh if we go here oops we have one

38.48

left

39.68

from our little uat and we're gonna deal

42.16

with time frame

43.2

and deleting it so now it's been a while

45.84

so let's go back to that

47.76

within this one let's create a time

49.36

frame and this one's going to be

53.84

just where it's at so this will be

57.039

parent delete me

64.479

and i want to save a record

67.68

and then i'm going to create a child

68.96

time frame which is going to be a

72.24

child delete me

73.94

[Music]

78.24

and so i should be able from there

81.84

now this is interesting is i can't from

83.68

here go back to

84.96

my parent oh child delete me should be

88.24

parents should be i'm sorry i should do

90.159

that

91.68

okay so now if i go back to my road maps

93.759

go here

94.96

parent delete me has one child has one

97.2

child

99.2

and so now what i want to do is make

100.64

sure that when i delete

102.24

the parent it's going to delete the

103.68

child and let's see what happens if i

105.04

delete it

108.24

now child delete me is going to show up

110.479

it gets moved up

112.32

which may have been what i decided to do

114.399

oh so now it just it takes the children

116.399

and moves it up so i may be actually

118

good with this

122.24

and so a child delete me has two zero

125.36

children if i delete that record

127.439

then i'm good so actually i think we

130.8

covered what we needed to we may fix

132.319

this

133.12

in a prior one and now if we go to

135.36

immediate we have

136.48

only this task which is now complete

140.319

and boom we are done so now that takes

144.16

us to

145.84

the uh the next step which is going to

148.239

be deploying

149.52

our application

153.2

and when we want to move this over

154.56

there's really there's a couple things

156.239

we need to do

158.08

this episode i want to just uh with the

160.16

little time we have in this one

162.16

i want to go ahead and talk about the

163.519

files we're going to move and then we'll

164.72

actually talk about

165.599

setting up a production django server in

168.72

our last episode

170.959

because there are some tricks to it as

173.2

we currently see we've got this thing

175.68

while this is mapped out pretty nicely

178.159

normally

178.879

when you're running django particularly

181.28

if you look in our

182.319

settings we're gonna see

186.159

that there's some things that you're not

187.599

supposed to do

189.36

and where is it at

192.8

uh there it is some things you're not

194.879

supposed to do in production

196.959

for example security warning if this was

200.48

a key

201.2

for production then we're going to have

203.12

to keep that secret

206.64

uh and that's used for a couple

208.239

different things for security

209.68

purposes you may have noted that here

212.319

while we are https right now

215.28

uh typically you're not going to have

216.64

that from the default and so there's a

218.799

couple of things we want to do

220.64

as well django typically is not going to

223.12

be your front end

224.72

it's going to be your friend and web

225.68

server you're going to have it fronted

227.28

by

227.84

you know maybe like a nginx or something

230.4

like that or

231.36

more commonly apache which is what we're

233.599

going to show

234.64

in that episode but first

238.239

now we have talked about in the database

240.56

side

241.76

that we can take these things and we

243.04

have our migrations that we can use to

245.68

build our database from scratch

248.4

so if we wanted to we could come in and

252.959

completely recreate our database using

255.84

our migrations

257.519

we're not going to do that this time

259.12

what we want to do

260.56

is we're going to go in and we're going

261.68

to do what's called mysql dump

265.68

and we're just going to take our

266.56

database and we're going to move the

267.919

whole thing over

269.199

the way you do that is you're going to

271.12

give it a

272.24

u which i think is going to go back to

275.28

my settings always forget my database

279.68

user's root password is developer newer

282.4

for this particular one

288.639

and so all i need to do is i'm going to

290.96

take my database what's the name of my

292.88

database

294.84

is tp project

297.57

[Music]

299.84

and i'm going to do it to dproject

303.44

dot sql so i'm going to do is take my

304.96

entire database

306.56

and i'm going to dump it out to a sql

308.479

file that would allow me to recreate

310.96

so i do that and now if i look

314.4

let's go look at that real quick if i

316.72

look at that

317.6

sql file i'm going to see that's got a

320

whole bunch of stuff

321.12

and that's going to come into each of

322.24

the tables down here and it's going to

323.919

see

324.639

if it exists drop it and then in here

327.84

we're going to see

330.72

as we go down let's scroll down a little

332.24

bit we're going to see here

333.919

if you look down here we're going to see

336.24

where it's actually going to

337.199

insert some records and things like that

339.36

no it does not

340.4

actually set a database

343.44

so what we can do

346.72

is i'm going to go back into the same

351.84

i'm going to go in i'm going to use this

353.12

command line there are other ways you

354.32

can do it

355.039

i'll show my databases

358.56

and if i do use dp project

362.319

show tables

365.68

all right so here's a bunch of tables so

367.039

now what i'm going to do is i'm going to

368.16

create database

370.16

uh i'm just going to call it example

374.08

i'm going to use example use that

375.84

database and then if i pull

378

in dp dpproject.sql which is in the

381.12

current directory of where i just ran

382.8

this

384.16

then now i'm here i'm going to see that

388.08

i just created all my tables so if i do

390.479

select star from

395.44

oh what did i call it like dp project

399.12

task i'm going to see a whole bunch of

402.08

information

403.36

which is all my tasks so i can see here

405.44

like set task background color based on

407.28

status

408.16

and i can see the information so i just

409.84

completely

411.759

re copied replicated my database now let

415.199

me do drop database

420.84

example and quit out so

423.44

what i have now is i have my little

427.44

sql file that is my database now the

430.72

files themselves

432.4

there's a couple different ways we can

433.68

do it from our purpose what we want to

435.919

do

436.4

is we've been using get all along that's

439.44

git

441.44

and i think if we go

445.44

out here if we go out to our github

448.84

account

451.039

and see where we've got let's see here

454.479

and we can actually

458.08

clone so

461.28

if i take that link and i can just copy

463.68

it

464.72

i could jump on a new server and let's

467.199

just say we're going to do a new

470.72

directory so i'm just going to do make

473.68

dir

474.56

temp make dr temp cd temp

478

and then do a git clone that

483.28

and then i'm going to see that i have my

486.16

project

487.36

i can go in here and i could actually if

490.4

i wanted to

491.599

run it i don't think let me kill this

493.36

one because i don't think it's going to

494.479

like having two

498.639

and let's let's just get down here and

502.319

let's just run it

512.64

oop that's not the manager's not there i

515.039

gotta jump up one more pro

516.719

level now run it

522.56

and boom now i'm running my i'm running

524.56

my application again

526.72

so it's actually fairly easy for what

528.72

we've got because we've been using

530.56

github all along because we've got our

533.68

database set up in such a way that we

535.279

can easily

536.399

dump it and and restore it then

540

we're going to be in a simple situation

541.68

of being able to replicate this

543.12

somewhere else

544.48

and this assuming we're going to move to

545.839

a production server

548.24

and we'll take a look at that this next

550.8

time around we'll actually go set this

552.32

up on a production server i'm going to

554.48

get a i'll connect to a different server

557.279

so we'll be able to actually see some

558.56

stuff out there but what we're going to

560.64

do is and we will just all we're going

562

to have to do

562.72

is depending on how you copy it you can

564.56

either do a scp

566

so i could do first let's get rid of

569.839

temp

574.16

and then if i go out to my

577.279

whoops

581.2

oh environment

584.959

there we go and so i've got my

588.8

so i could just do scp dpproject.sql2

593.68

you know my username

597.12

at some number or some ip address or

600.88

something like that

602

and a home switch my username and if i

606.24

do that then it's going to copy that

607.44

file out this won't because it's going

608.8

to say

609.519

that doesn't exist and i'm going to do

612.64

the same and

613.519

actually i'm just going to do a git

615.6

clone on the other side

617.2

and be able to pull all of my uh files

620.079

down

621.12

and of course that does you know assume

624.32

that we've been committing along the way

627.2

now typically i think we sort of skipped

630.24

over a little bit

631.76

but all you have to do is really if you

633.76

do a get

635.839

dash add dot it's going to add all your

637.76

changes

640

i'm sorry god

648.32

oh one second

651.44

i can i reverse those two it's a get ad

654.64

there we go so if i do a get add dot i'm

657.68

going to see if there's anything here

659.68

i can do a git commit and i'm going to

662.959

give it a comment of some sort and it's

664.399

going to commit stuff and i can do that

665.68

right now because i don't want to commit

666.8

my sql file

668.959

and then we can tag it and you will see

672.64

much as we have here then you'll be able

675.519

to come in here

676.56

and you can clone it out and you can see

678.32

where we've got uh

680.399

somewhere in here code i think i've got

682.8

oh here's my tags

684.72

um i can probably see commit somewhere i

687.44

forget where i get to see all my commit

689.04

history but

689.839

i can see this tag i can pull this it'll

692.72

i can actually pull the zip file or

694.959

uh tart and gzipped file if i wanted

701.2

let's see so let's go back to our code

707.839

and i can see i've got some branches

711.279

and yeah that's enough for there that's

713.279

enough for the kit up

714.399

hub stuff that stuff you can pretty much

716.32

play around with

718.399

and we are going to clone that out now

720.88

the tricky part is going to be

722.639

our static files and

726.32

where is that because this currently is

728.32

being served

730.32

if we look in our settings it's

732.24

currently being served from

735.04

a slash static but what we could end up

738

doing

738.399

is we could actually which we're going

739.839

to show ourselves next time as i can go

741.519

out to http colon backslash

743.519

let's say mysite.com

746.639

static and i can shove all these files

748.72

there

750.48

and it's going to pick them up and

752.959

that's going to be

753.839

our where our apache front end

757.44

is going to pick those files up so we've

758.8

got a couple things we've got to

760

configure

761.36

and i want to make sure that we sort of

762.8

mention those uh before we get too far

765.68

into this and that's going to be our

768.16

that's going to be our last episode

769.2

we're not going to worry about this one

770.56

is we're going to come in we're going to

772.24

have a

773.2

another place we're going to have a

774.399

server that we're going to configure

776.639

well it's going to be configured and

778.399

we're going to configure our django app

780.24

on it so

781.36

just as sort of a heads up if you're

783.36

wanting to follow this all the way

784.72

through if you've got a server

786.56

somewhere then that you're going to

789.76

deploy to that's going to be your we'll

791.04

call it your production server make sure

792.88

that you have git configured

795.04

make sure you have my sql already

796.48

installed and make sure that you have

798.959

apache on there and then we'll walk

800.56

through those pieces

801.6

and that'll be our final episode so

804.8

as always until then have yourself a

807.279

great day and we will talk to you

809.68

next time

827.12

you