📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 58

2021-05-25 •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 code at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
hello and welcome back
we are going to work on actually sending
our site
that we've been working on put our
application out on a uh we'll call it a
production server
hopefully you have one set up
and we're going to walk through it some
of this little some things we've talked
about before but and we'll get ourselves
started here
and get into uh in this case what we're
gonna do is we're gonna have the
django server and it's going to be
front-ended by an apache server
and we're gonna clean up a couple of
things that we have set for us at this
point
to give us our development version of
the django server
the first thing we're going to do as
mentioned before we're going to go over
and we're going to grab our code
so i'm going to grab my code here
and i'm going to do a get clone
with that that link
and so now i'll see if you saw some over
here
uh it opened up alright created here's
my project
and so i can go in there and let's see
what happens now the first thing i'm
going to do
if i try to run it is it's probably
going to
fall apart
so here because i've got
i'm missing probably a module here
so although i've got python set up i do
not have everything else set up
and so what i'm going to need to do is
i'm going to have to actually go through
and make sure that i have my use pip3 or
pip i guess you know pip3 in my case
and make sure that we've got everything
straightened out so let's go look at our
this one real quick so manage
uh if it goes to
line 22 let's see what it says this may
point us in the right direction
uh man so it's probably os and cis let's
just
check those real quick
and this
and so it is complaining about our base
command so let's see let's go look at
so we're at three five
so we should be okay
but we probably need to upgrade it so
let's go ahead and in this case we may
have to do an update
so we're going to go ahead and check
that first one
so let's go ahead and uh so whoop
down update
[Music]
oop this is going to be probably apt-get
so we'll go ahead and update this and
then we're going to have to do
let's do python 3.7 i think is how it
goes
okay we're going to actually change this
over because i don't like how it's
referring to
now let's try this
there we go okay so now we're going to
have some issues with getting our
database together
probably
so let's go look here uh where's our
installed apps that's all
good databases we don't need our test at
all
and then this one we're going to have to
actually create
a user so we're going to call it um
dev user well i'll get rid of the
underscore and we'll give it a password
of uh we'll give it basically the same
thing we're just going to change it up
a little bit
and so now what we need to do is we're
going to actually create that user
so we want to do is we want to jump into
my sql
and we need to do create user uh we're
gonna call it dev user
and uh we're gonna just paste this in
and we're gonna change this around a
little bit because i stole this because
i
always forget the exact thing so this is
going to be
create user i'm sorry tab user
at localhost and it's going to be
identified by
i'm going to give it the password
come down here give it the password
and i'm going to do the same thing and
do it with a wild card just because
because that sometimes can be an issue
so now i've got that created
and then i need to grant all on
star 2
this guy
oh i'm not a um
i need to be roots so let's do that
oh i think i can do it this way
and now if i do grant oh
let's start out star
two there we go
[Music]
percent
cross privileges
if i can spell it right
okay so now let's go back out here
so um bring in our database we already
looked at that you can create a database
source pull that in and i've actually
done that here
so now if i do let's make sure i can see
it so if i do dev user
p password is
oh paste it here
okay so i can do show databases
and i can see dp project
okay so good so i'm able to use it and
so
i can quit now now let's go back and try
to run
and oh did i oh i forgot to save that
and so now it's running so let's go see
if
okay so i'm not getting that and if i
look here it's not getting through here
at all
so what i need to do is open it up
oh it has a lot of hosts is wide open
so let's try to do this let's actually
run it on
there
and now let's see what we get
okay so now we are coming through
log in so i'm able to see this i don't
care to save that
um oh i guess i can blow this up a
little bit so we can see a little bit
more
and so if we go to our goals there's
nothing there if we look at our roadmaps
but we've got it because we've pulled
all our data in
and we're now running off of our other
server and we can see here from our
debug stuff that we now have our server
running
on our our demo our dev server running
on
the other side so now let's start
cleaning some stuff up
so we don't want to run with debug
turned on
on production we're going to change our
secret key at some point but we'll just
right now not worry about it too much so
we have
all of that
and now if we run we should get the same
thing we should still be able to
run
wow everything's complete there
let's pick some that are different oh
wow that was interesting that one just
totally blew up on us so what we're
going to run into
probably oh because
this is now it's picking it up that it's
production we're going to find
an error here i think
because if we take that same one let's
go back to debug
equals true
so it's here and we're gonna see if it's
false
and it's gonna blow up on us i think
well when it tries to reload
i'll shoot okay
let's do this
oh maybe it's not going to blow up on us
okay
all right well typically what happens is
it's going to end up because it's going
to the wrong
static as we start to turn stuff on so
let's go to here and what we have now is
we have it actually running
our application we've got our database
set up we've got our password
all of our blah blah blah blah blah it's
really not much else we have to do
except
we're going to deal with this static and
you're going to see right here
we'll go ahead and use their little
documentation
and we're going to see that here
let's see that's during development
serving files testing deployment
uh so here we go so we're going to have
a static route
for getting to our server so instead of
putting all them here we're going to
actually put them
out on our site somewhere and of course
we're going to do is copy all of our
files from our static into our static
route
and so here let's create
oh i'm just going to take a let's stop
this
and so now what we want to do is
we're going to go to our website and
we're going to make their
uh we need to do a pseudo
and we're going to call it dp static
and if you'll see here we don't want it
owned by root we want it owned by wwe
data
so we're going to do sudo
r just to make sure we get anything
underneath
i do that for dp static
and so now it's good now if we go to see
there now what we want to do is we need
to copy everything
that is here we need to copy this static
over to the other static so what we want
to do
what we want to do is we want to pull
our static files over so we're going to
go here
to our um
where did that go go here
oh one more level up and we're just
gonna do tar
uh put it back here static
star oh we gotta call it
static.tar that
uh let's not do that
we won't actually go up one more
because we're going to do it so that
it'll come from here and now we want to
do tar
whoops till the whoop come here
till the slash static tar star
oh and it's going to be a cvf my mistake
okay so there we go so now we can go
here
and go back to our static on our web
and then we're going to do a tar dash
xvf
our static files here so now they're all
here and so now
if we look we should be able to do
see demo one
dp static so let's make sure that that
actually
gives us something
and we can see here that we've got our
folders
so which is this is not a production
server normally you wouldn't be able to
see that so now
if we do that and we're now going to go
back to
our application
i guess this path yes this path
and we're gonna go kick this guy off and
let's see what he does for us
uh where we go here we go
and so now uh let's get rid of that for
right now
let's get rid of that for right now
and we're going to see here
let's go to like a task list here and if
we look
into our developer tools
we're going to see uh sources
and we're going to see that here we go
like dp static css it's pulling that
up so
now we did see that it didn't like
jquery
so dp statics js jquery didn't we not
have that
let's see if we go to static js
now somehow that got moved
so let's uh let's see so is that jquery
mint whoops
let's just check that real quick so he
was trying to find
jquery.js
and bootstrap bundle men so let's go
check those guys real quick bootstrap
bundle man.js should be there
so let's go check our website real quick
go to js
so he should see
bootstrap dash bundle dot
i'm going to give you the full path uh
whoops let's go check that real quick
uh dp static js bootstrap dash
bundle dot men
bundle dot man dot js
not finding it and so let's go back and
look for that
oh bootstrap.bundle
so let's just copy that
bundle dot min dot js2
bootstrap dash
bundle dot min dot js
and then we're going to also copy the
jquery
to i think we just called it jquery.js
and so now if we go look
non js module files so we just blew
something up
pretty heavily there
let's go look here
oh because our server's down so let's go
back over here
oops i think that's it let's run our
server
where'd he go there we go
okay so now if we look at our console
good we got our stuff
and things are showing up
there we go okay so now we've got and
like i said if we look at our sources
we're going to see that we're coming off
of
static so we've got our static stuff
coming through
and so now what we're going to do is
we're going to actually front
the next thing we're going to do is
we're actually front the
the servers so we're not going to be
using this anymore
we're going to actually be able to come
through and that is going to be
in the next episode and once we've got
that then we will be off and running
we'll be able to
redirect we can use our you know dns's
namespace and we can actually redirect
and we're also going to do
our https connection since if you
haven't noticed
we have been unsecure and if we do this
it's going to blow up on me see i can't
get there because i can't do
i provide a secure connection so we're
going to get all that stuff straightened
out next time so
that's something to look forward in what
will probably be a part two in our final
episode
in this series on django and python
we'll catch that next time but until
then
have yourself a great day and we will
wrap it up next time
you
Transcript Segments
0.46

[Music]

26.24

hello and welcome back

27.84

we are going to work on actually sending

30.56

our site

31.519

that we've been working on put our

32.64

application out on a uh we'll call it a

34.96

production server

36.88

hopefully you have one set up

39.92

and we're going to walk through it some

40.96

of this little some things we've talked

42.719

about before but and we'll get ourselves

44.8

started here

45.52

and get into uh in this case what we're

48

gonna do is we're gonna have the

49.84

django server and it's going to be

51.76

front-ended by an apache server

54.64

and we're gonna clean up a couple of

55.76

things that we have set for us at this

58.32

point

59.199

to give us our development version of

62

the django server

63.52

the first thing we're going to do as

66

mentioned before we're going to go over

67.439

and we're going to grab our code

69.439

so i'm going to grab my code here

73.439

and i'm going to do a get clone

76.56

with that that link

79.92

and so now i'll see if you saw some over

82.479

here

83.68

uh it opened up alright created here's

86.72

my project

88

and so i can go in there and let's see

92.079

what happens now the first thing i'm

93.119

going to do

93.68

if i try to run it is it's probably

95.68

going to

99.04

fall apart

104.159

so here because i've got

107.92

i'm missing probably a module here

112.64

so although i've got python set up i do

114.479

not have everything else set up

117.6

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

119.04

i'm going to have to actually go through

121.2

and make sure that i have my use pip3 or

124.399

pip i guess you know pip3 in my case

126.88

and make sure that we've got everything

129.599

straightened out so let's go look at our

133.28

this one real quick so manage

137.28

uh if it goes to

140.64

line 22 let's see what it says this may

142.8

point us in the right direction

147.599

uh man so it's probably os and cis let's

150.4

just

151.28

check those real quick

162.64

and this

172.08

and so it is complaining about our base

174.48

command so let's see let's go look at

179.68

so we're at three five

182.8

so we should be okay

187.68

but we probably need to upgrade it so

192.959

let's go ahead and in this case we may

194.959

have to do an update

196.72

so we're going to go ahead and check

198.239

that first one

200

so let's go ahead and uh so whoop

204.56

down update

207.7

[Music]

211.28

oop this is going to be probably apt-get

218

so we'll go ahead and update this and

219.68

then we're going to have to do

224.72

let's do python 3.7 i think is how it

228.239

goes

229.44

okay we're going to actually change this

230.799

over because i don't like how it's

232.319

referring to

234.72

now let's try this

238

there we go okay so now we're going to

240

have some issues with getting our

241.439

database together

242.64

probably

245.84

so let's go look here uh where's our

249.76

installed apps that's all

253.2

good databases we don't need our test at

256.16

all

259.199

and then this one we're going to have to

260.479

actually create

262.56

a user so we're going to call it um

267.199

dev user well i'll get rid of the

269.28

underscore and we'll give it a password

271.52

of uh we'll give it basically the same

275.6

thing we're just going to change it up

278.08

a little bit

284.24

and so now what we need to do is we're

286

going to actually create that user

289.36

so we want to do is we want to jump into

291.199

my sql

297.919

and we need to do create user uh we're

300.639

gonna call it dev user

303.52

and uh we're gonna just paste this in

305.52

and we're gonna change this around a

306.72

little bit because i stole this because

308.4

i

308.72

always forget the exact thing so this is

311.039

going to be

311.759

create user i'm sorry tab user

315.759

at localhost and it's going to be

318.68

identified by

321.68

i'm going to give it the password

326.8

come down here give it the password

329.84

and i'm going to do the same thing and

331.36

do it with a wild card just because

335.12

because that sometimes can be an issue

337.28

so now i've got that created

339.44

and then i need to grant all on

345.6

star 2

349.84

this guy

354.32

oh i'm not a um

358.639

i need to be roots so let's do that

363.44

oh i think i can do it this way

371.039

and now if i do grant oh

374.4

let's start out star

379.199

two there we go

382.13

[Music]

388.4

percent

391.6

cross privileges

396.08

if i can spell it right

400

okay so now let's go back out here

403.28

so um bring in our database we already

406.56

looked at that you can create a database

408.24

source pull that in and i've actually

409.919

done that here

412.72

so now if i do let's make sure i can see

415.199

it so if i do dev user

418.639

p password is

423.52

oh paste it here

426.8

okay so i can do show databases

430.88

and i can see dp project

438.08

okay so good so i'm able to use it and

440.96

so

441.36

i can quit now now let's go back and try

444.4

to run

447.199

and oh did i oh i forgot to save that

455.52

and so now it's running so let's go see

457.919

if

461.84

okay so i'm not getting that and if i

464.08

look here it's not getting through here

465.919

at all

466.879

so what i need to do is open it up

470.8

oh it has a lot of hosts is wide open

476.24

so let's try to do this let's actually

477.919

run it on

484

there

487.039

and now let's see what we get

495.12

okay so now we are coming through

501.599

log in so i'm able to see this i don't

505.44

care to save that

507.68

um oh i guess i can blow this up a

511.12

little bit so we can see a little bit

512.399

more

514.8

and so if we go to our goals there's

517.12

nothing there if we look at our roadmaps

518.719

but we've got it because we've pulled

519.919

all our data in

520.8

and we're now running off of our other

523.68

server and we can see here from our

525.68

debug stuff that we now have our server

528.64

running

529.12

on our our demo our dev server running

532

on

533.44

the other side so now let's start

536.56

cleaning some stuff up

538.08

so we don't want to run with debug

541.68

turned on

542.32

on production we're going to change our

545.36

secret key at some point but we'll just

547.839

right now not worry about it too much so

550.959

we have

552

all of that

555.6

and now if we run we should get the same

557.68

thing we should still be able to

560.839

run

564.72

wow everything's complete there

569.68

let's pick some that are different oh

571.44

wow that was interesting that one just

573.279

totally blew up on us so what we're

576

going to run into

576.959

probably oh because

580.16

this is now it's picking it up that it's

582.24

production we're going to find

583.6

an error here i think

589.68

because if we take that same one let's

592.72

go back to debug

594.24

equals true

602.24

so it's here and we're gonna see if it's

604.88

false

610.48

and it's gonna blow up on us i think

613.92

well when it tries to reload

617.04

i'll shoot okay

621.76

let's do this

631.36

oh maybe it's not going to blow up on us

633.6

okay

642.88

all right well typically what happens is

645.6

it's going to end up because it's going

646.88

to the wrong

648.16

static as we start to turn stuff on so

651.6

let's go to here and what we have now is

654.48

we have it actually running

655.6

our application we've got our database

657.279

set up we've got our password

659.04

all of our blah blah blah blah blah it's

661.6

really not much else we have to do

662.88

except

664.8

we're going to deal with this static and

667.2

you're going to see right here

668.399

we'll go ahead and use their little

672.839

documentation

675.6

and we're going to see that here

683.92

let's see that's during development

686.24

serving files testing deployment

688.24

uh so here we go so we're going to have

690.24

a static route

693.12

for getting to our server so instead of

695.6

putting all them here we're going to

696.64

actually put them

697.839

out on our site somewhere and of course

700.72

we're going to do is copy all of our

702.24

files from our static into our static

704

route

705.279

and so here let's create

709.6

oh i'm just going to take a let's stop

712.16

this

712.88

and so now what we want to do is

716

we're going to go to our website and

718.48

we're going to make their

720.16

uh we need to do a pseudo

725.2

and we're going to call it dp static

728.48

and if you'll see here we don't want it

730.16

owned by root we want it owned by wwe

732.079

data

732.56

so we're going to do sudo

736

r just to make sure we get anything

738

underneath

743.2

i do that for dp static

746.959

and so now it's good now if we go to see

750.639

there now what we want to do is we need

752.399

to copy everything

755.839

that is here we need to copy this static

759.92

over to the other static so what we want

761.76

to do

762.959

what we want to do is we want to pull

764.079

our static files over so we're going to

765.519

go here

766.88

to our um

770.24

where did that go go here

773.68

oh one more level up and we're just

776.399

gonna do tar

778

uh put it back here static

781.68

star oh we gotta call it

785.639

static.tar that

791.68

uh let's not do that

797.04

we won't actually go up one more

801.44

because we're going to do it so that

802.399

it'll come from here and now we want to

804.079

do tar

805.76

whoops till the whoop come here

809.12

till the slash static tar star

812.959

oh and it's going to be a cvf my mistake

816.8

okay so there we go so now we can go

818.88

here

819.92

and go back to our static on our web

826.16

and then we're going to do a tar dash

828.079

xvf

830.24

our static files here so now they're all

833.12

here and so now

835.199

if we look we should be able to do

839.279

see demo one

845.839

dp static so let's make sure that that

848.959

actually

849.76

gives us something

854

and we can see here that we've got our

856.88

folders

858

so which is this is not a production

860.639

server normally you wouldn't be able to

861.76

see that so now

863.04

if we do that and we're now going to go

866.56

back to

867.36

our application

871.12

i guess this path yes this path

874.24

and we're gonna go kick this guy off and

877.36

let's see what he does for us

878.8

uh where we go here we go

886.079

and so now uh let's get rid of that for

889.36

right now

889.92

let's get rid of that for right now

893.68

and we're going to see here

896.8

let's go to like a task list here and if

899.12

we look

901.36

into our developer tools

910.639

we're going to see uh sources

916.56

and we're going to see that here we go

917.92

like dp static css it's pulling that

920.16

up so

923.839

now we did see that it didn't like

925.76

jquery

930.24

so dp statics js jquery didn't we not

933.839

have that

937.759

let's see if we go to static js

943.44

now somehow that got moved

947.6

so let's uh let's see so is that jquery

950.399

mint whoops

951.92

let's just check that real quick so he

955.04

was trying to find

958.04

jquery.js

963.68

and bootstrap bundle men so let's go

966.32

check those guys real quick bootstrap

968.639

bundle man.js should be there

976

so let's go check our website real quick

981.519

go to js

984.959

so he should see

991.36

bootstrap dash bundle dot

998.56

i'm going to give you the full path uh

1001.839

whoops let's go check that real quick

1006.959

uh dp static js bootstrap dash

1010

bundle dot men

1019.519

bundle dot man dot js

1024.079

not finding it and so let's go back and

1026.4

look for that

1029.12

oh bootstrap.bundle

1033.199

so let's just copy that

1038.24

bundle dot min dot js2

1041.319

bootstrap dash

1044.72

bundle dot min dot js

1048.64

and then we're going to also copy the

1050.88

jquery

1053.76

to i think we just called it jquery.js

1059.52

and so now if we go look

1066.48

non js module files so we just blew

1069.039

something up

1069.679

pretty heavily there

1077.6

let's go look here

1080.72

oh because our server's down so let's go

1083.36

back over here

1088.4

oops i think that's it let's run our

1091.039

server

1093.12

where'd he go there we go

1098.24

okay so now if we look at our console

1101.039

good we got our stuff

1103.44

and things are showing up

1107.28

there we go okay so now we've got and

1110.24

like i said if we look at our sources

1111.52

we're going to see that we're coming off

1113.2

of

1114.799

static so we've got our static stuff

1117.2

coming through

1118.72

and so now what we're going to do is

1120.799

we're going to actually front

1123.76

the next thing we're going to do is

1124.88

we're actually front the

1127.52

the servers so we're not going to be

1128.88

using this anymore

1130.559

we're going to actually be able to come

1131.84

through and that is going to be

1134.32

in the next episode and once we've got

1136.24

that then we will be off and running

1137.76

we'll be able to

1139.2

redirect we can use our you know dns's

1142.559

namespace and we can actually redirect

1144.799

and we're also going to do

1146

our https connection since if you

1148.799

haven't noticed

1150.24

we have been unsecure and if we do this

1154.32

it's going to blow up on me see i can't

1157.679

get there because i can't do

1159.039

i provide a secure connection so we're

1160.64

going to get all that stuff straightened

1161.52

out next time so

1163.28

that's something to look forward in what

1164.88

will probably be a part two in our final

1166.64

episode

1167.44

in this series on django and python

1170.4

we'll catch that next time but until

1171.679

then

1172.48

have yourself a great day and we will

1175.44

wrap it up next time

1193.28

you