📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 32

2021-02-16 •Youtube

Detailed Notes

Our focus today is on self-referencing models as we start to provide for timeframe parent-child relationships.

You can view source for today and all prior days by reviewing the tag Day 33 (32 and 33 were combined in that tag) at this GitHub address: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
well hello and welcome back
we are continuing our python django
series tutorials
and we are digging into building out our
application
today we're going to uh make it a little
more like an application we've been
essentially hacking our way through some
of these things making some
uh yeah making some sort of quick fixes
and quick links and stuff like that
and we're gonna start moving forward
into you know cleaning it up a little
bit
so first thing we'll do is we're gonna
start with the login page
and so here you can see we come in and
we've got a login that's sort of you
know in the way there and so whoops
let's go over here
and let's go to our login which i
believe
was home page maybe oh no it's login
here
and this extends base i think we have
everything we need
instead of simply doing this
login and then a form method uh let's go
ahead and center it out a little bit so
we're just going to do
div class equals container so i think we
looked at that before
and this just gives us a
sort of a general let's see in block
whoops i want to put it before the end
block
and it's going to give us something so
we can put it inside so if i just save
this
so it's going to clean it up just the
slightest amount
so i go here now it's over because
remember we have is our container we
have some
gutters on both sides but now let's take
that
and we're going to take him and do
uh let's see we'll do it within here so
we're going to do
and we're just going to do it it's going
to be a full length so it's going to be
a
col we're gonna do an md and this is a
bootstrap
thing uh let's see table there we go
and what this does basically you can
within bootstrap
you have uh essentially it divides the
screen the page into
12 spots 12 columns essentially
and those adjust based on whether or not
you're shrinking your screen or not
so right now we're going to say this is
basically effectively a whole row
which we could actually let's just keep
it a row for now
and i think we can do an align equals
center
and clean it up just a little bit so if
we go here
oh that's not what i wanted to do
so let's do it this way we're going to
cheat um this is another way to center
stuff so we're going to come in
and we're going to do let's have a row
we're gonna do class equals remember you
i just mentioned that you can
split uh bootstrap allows you to split
stuff up
in twelfths essentially so we're gonna
say
that that's probably and about a third
so what we can do is
we're going to do a responsive
split in bsp so we're going to give it a
space because it
wants a space within that div
and then we're going to do three such
divs so let's see so we do that one that
one
that one and this one
make sure i've got that balanced so now
what we're doing is we're saying i want
some
i want a bigger column basically to left
a bigger column to the right and then
put the other one in the middle
and it's still not picking it up right i
wonder why it's not oh
i bet it's not let's go look back at
bass because it may not be picking up
bootstrap which could be part of my
problem
uh it should be picking that up
so let's go take a look at that real
quick
and we're gonna see here he's an md4
and if we look at the style here
let's see so md4 is picked up by
grid scss
oh you know what it is is because i'm
not forcing that thing to be a
row let's just go back here
and wrap that thing in a row and see
what happens
because otherwise it's just going to
sort of split spread stuff out as
it deems necessary
which essentially will end up stacking
them so if we looked here
so yeah here if you look here the first
md4 is actually it's unknown
it's its own row the next one is a row
the next one is row
but now oh and i need to change my login
now because we put it within a row if we
go into the container and look
within that row now we see our fours
beside each other
and so let's just change the please log
in i think i can do it on line equals
center
let's see if that works if is it that
simple
yes okay so i can do please log in i'm
going to make it an
h2 and i'm just going to slap
a couple of rows
above that let's do three of them
now i could make this something where
this header is through css
let's do it this way i could make it so
that that is spaced out you know
specifically i could do
a login form or something like that but
i'm keeping it source simple here
uh whoop i don't want to save it i want
to do that
and so now we log in now one of the
things once we log in
we go to this home page which is not
terribly interesting what i want to do
is i'm going to change it i'm going to
go right to my to-do list
so that means within my views
actually i can probably see it
if i go to my login uh
let's see oh well let's go look at that
let's go look here
where's login login log in
let's see so i may have sent it
and let's go take a look at that i think
well let's go look at our url so when i
come into homepage
homepage will redirect to login
which redirects
to probably default
let's see so if we go
here it's going to do a login it's going
to submit
now one of the things we saw before is
that i think we've talked about the
ability to
forward like if we look at our i think
it's in base
i go page home what was our other one
internal uh that also does
so let's flip back over here
so what we want to look at where was the
actual homepage homepage here
uh this is the homepage so let's go see
what we're displaying
a whole page
okay so we must be doing that here oh
here we are
oh that's home too i don't think we need
home too nor do we need about
oh here we go i'm sorry so uh profile
we've got our
template name is homepage.html
and instead what we want to do
is because i think we can do it this way
is we're going to go to our active tasks
which is our to-do
as we see up here so now if we do active
tasks
okay so that should work so now if we go
in here
and we log out and we log in now it
brings us to active tasks
and so home uh is bringing us to login
so let's take a look at that
let's see so we want to go to that's our
internal
and so home here takes itself slash
which takes us to home page oh and what
we want to do here we're just doing a
redirect
instead we want to say if we are logged
in
which i think we've used that before
so i may not so we can do it here and
what we're going to do is we're going to
say if request
got user so if we're logged in
then we're going to redirect to
the to do
otherwise and we'll just let it fall
through otherwise we're gonna redirect
to the
login now what this does is this
basically says hey if i'm logged in
then i can go one place and if i'm not i
can go somewhere else
and this is something we can use
actually and probably will start
hooking up in several places
oh and actually it's not as you i'm
going to do is
authenticated and dk
did and actually what we can do
is let's just we're going to use this in
a couple places so if not
request.user is authenticated so if
they're not logged in and then in that
case
we're going to redirect them to the
login
and otherwise they go to the to do
and so actually we can do that here to a
couple of things so like completing a
task
let's make sure that they're logged in
uh show page we have to worry about that
uh user registration form no creating a
task let's make sure that they are and
these are because we're using the
request.user
we want to make sure that they're
validated
uh let's see don't worry about test mass
update definitely
uh edit a task we definitely need to be
logged in
listing our tasks listing our road maps
creating a road map
and so this is also going to help us in
several cases where we were
setting the owner to a request user if
there is no request user which means
they're not authenticated
then we're going to run into some issues
let's see active tasks
edit the time frame so we're going to
start doing this as part
of our our views
is we'll just make sure that we are
authenticated so now
i've gone through we've done that if i
do a login
and now if i do a home it's going to
come here if i log out
and i do a home oh actually i can do it
from here
in this case it's going to bring me back
to login so now it's not going to keep
kicking me back to log in
and let's see so i can i'll leave
well because i'm going to come to home
i'm going to get rid of to do
out of my menu items
so i can get rid of that and that's in
internal
so i don't need to worry about that
anymore
and now let's continue with our
application so now
we're going to come in here we see this
well if you remember we were working on
our roadmaps
so our roadmaps we've got one
and we could create a new one if we want
but let's keep with this one so let's
sort of
flesh out this road map so this road map
we've come in we've got a due date
we have some time frames
so we've got overall annual goals and
then we've got
um first quarter now what we wanted to
do is we wanted to be able to set a
a time frame to have uh another time
frame
as a parent and so let's go jump into
that
um actually let's not this time
uh so let's go in and uh we're going to
do because we're going to have a couple
of things we're going to pick up next
time
because we are short this time around so
then one of the things we want to do
and we i think we already did it is for
our overall annual goals we added
some tasks now we can do that
also for our quarterly goals
so i can create for this period let's
say
i'm going to create uh application
version one
so we'll have a couple of pieces of data
to work with next time around so create
application version one
due date uh march the end of march
we'll just pick a date towards the end
of that i'm not going to attach a file
it's not completed it is new
uh time frame and this is for the first
quarter
now one of the things we see here that
we're also going to tackle
is okay so i save that now there's two
things i came to here from first quarter
so what i'm going to want to do is use
that as essentially as a default
and i want a way to go back as opposed
to doing this you know back
which now i got to go back through this
and then i go back through it
what i want to do is i'm going to with
this
i'm now going to have a way to
essentially go back to
the period that i'm working with so
that's what we're going to tackle next
time
i've gone a little long this time
playing around with stuff but next time
what we're going to focus on
is having some sort of a structure
within our
tasks and our roadmap uh goals
so that we can you know time periods so
that we can start flushing this thing
out a little bit
that'll do it this time around so go out
there have yourself a great day
and we will talk to you next time
you
Transcript Segments
0.94

[Music]

26.4

well hello and welcome back

28.24

we are continuing our python django

30.56

series tutorials

31.92

and we are digging into building out our

34.559

application

35.92

today we're going to uh make it a little

39.04

more like an application we've been

41.36

essentially hacking our way through some

42.879

of these things making some

44.879

uh yeah making some sort of quick fixes

47.28

and quick links and stuff like that

49.039

and we're gonna start moving forward

51.12

into you know cleaning it up a little

52.719

bit

53.6

so first thing we'll do is we're gonna

55.44

start with the login page

57.12

and so here you can see we come in and

60.879

we've got a login that's sort of you

63.44

know in the way there and so whoops

65.119

let's go over here

67.2

and let's go to our login which i

71.52

believe

72.32

was home page maybe oh no it's login

75.92

here

78.479

and this extends base i think we have

82

everything we need

84.4

instead of simply doing this

87.84

login and then a form method uh let's go

91.28

ahead and center it out a little bit so

92.64

we're just going to do

94.32

div class equals container so i think we

97.2

looked at that before

99.759

and this just gives us a

102.88

sort of a general let's see in block

105.04

whoops i want to put it before the end

106.72

block

108

and it's going to give us something so

109.36

we can put it inside so if i just save

111.52

this

111.92

so it's going to clean it up just the

113.84

slightest amount

115.84

so i go here now it's over because

118.64

remember we have is our container we

120.159

have some

121.119

gutters on both sides but now let's take

123.119

that

125.119

and we're going to take him and do

128.8

uh let's see we'll do it within here so

131.68

we're going to do

136.319

and we're just going to do it it's going

137.599

to be a full length so it's going to be

139.36

a

140.239

col we're gonna do an md and this is a

142.72

bootstrap

143.36

thing uh let's see table there we go

149.84

and what this does basically you can

152.16

within bootstrap

154.879

you have uh essentially it divides the

157.04

screen the page into

158.64

12 spots 12 columns essentially

161.92

and those adjust based on whether or not

164.16

you're shrinking your screen or not

166.4

so right now we're going to say this is

167.92

basically effectively a whole row

170.56

which we could actually let's just keep

172.72

it a row for now

175.04

and i think we can do an align equals

177.599

center

179.92

and clean it up just a little bit so if

182.4

we go here

184.239

oh that's not what i wanted to do

190.239

so let's do it this way we're going to

191.84

cheat um this is another way to center

194.08

stuff so we're going to come in

194.959

and we're going to do let's have a row

199.84

we're gonna do class equals remember you

202

i just mentioned that you can

203.519

split uh bootstrap allows you to split

206.319

stuff up

207.599

in twelfths essentially so we're gonna

209.68

say

210.959

that that's probably and about a third

215.36

so what we can do is

218.72

we're going to do a responsive

222.239

split in bsp so we're going to give it a

224.72

space because it

225.76

wants a space within that div

230.72

and then we're going to do three such

233.519

divs so let's see so we do that one that

235.599

one

236.959

that one and this one

243.12

make sure i've got that balanced so now

244.64

what we're doing is we're saying i want

245.84

some

246.159

i want a bigger column basically to left

248.08

a bigger column to the right and then

249.36

put the other one in the middle

253.36

and it's still not picking it up right i

255.519

wonder why it's not oh

256.56

i bet it's not let's go look back at

259.199

bass because it may not be picking up

261.919

bootstrap which could be part of my

264

problem

266.8

uh it should be picking that up

270.88

so let's go take a look at that real

272.479

quick

275.44

and we're gonna see here he's an md4

280.08

and if we look at the style here

286.56

let's see so md4 is picked up by

290.8

grid scss

296.32

oh you know what it is is because i'm

298.56

not forcing that thing to be a

300.479

row let's just go back here

304.8

and wrap that thing in a row and see

307.759

what happens

310.32

because otherwise it's just going to

311.6

sort of split spread stuff out as

313.919

it deems necessary

317.039

which essentially will end up stacking

318.72

them so if we looked here

321.6

so yeah here if you look here the first

323.52

md4 is actually it's unknown

325.12

it's its own row the next one is a row

327.28

the next one is row

328.32

but now oh and i need to change my login

332.56

now because we put it within a row if we

335.68

go into the container and look

338.24

within that row now we see our fours

341.039

beside each other

343.12

and so let's just change the please log

345.68

in i think i can do it on line equals

347.28

center

349.28

let's see if that works if is it that

351.44

simple

353.039

yes okay so i can do please log in i'm

356.16

going to make it an

356.88

h2 and i'm just going to slap

360.319

a couple of rows

363.52

above that let's do three of them

370.56

now i could make this something where

372.16

this header is through css

374.72

let's do it this way i could make it so

376.479

that that is spaced out you know

378.24

specifically i could do

379.44

a login form or something like that but

381.6

i'm keeping it source simple here

384.08

uh whoop i don't want to save it i want

386.72

to do that

387.28

and so now we log in now one of the

389.919

things once we log in

392.319

we go to this home page which is not

394.319

terribly interesting what i want to do

396.24

is i'm going to change it i'm going to

397.199

go right to my to-do list

399.68

so that means within my views

404.72

actually i can probably see it

408.479

if i go to my login uh

411.759

let's see oh well let's go look at that

413.599

let's go look here

418.96

where's login login log in

423.84

let's see so i may have sent it

432.56

and let's go take a look at that i think

436.24

well let's go look at our url so when i

437.759

come into homepage

441.599

homepage will redirect to login

445.52

which redirects

450.319

to probably default

454.639

let's see so if we go

457.759

here it's going to do a login it's going

460.08

to submit

461.199

now one of the things we saw before is

463.44

that i think we've talked about the

465.52

ability to

466.72

forward like if we look at our i think

470.16

it's in base

473.44

i go page home what was our other one

477.759

internal uh that also does

482.319

so let's flip back over here

489.039

so what we want to look at where was the

491.12

actual homepage homepage here

495.44

uh this is the homepage so let's go see

497.599

what we're displaying

501.199

a whole page

507.36

okay so we must be doing that here oh

510.319

here we are

512.08

oh that's home too i don't think we need

514.24

home too nor do we need about

521.599

oh here we go i'm sorry so uh profile

524.48

we've got our

525.44

template name is homepage.html

529.36

and instead what we want to do

532.88

is because i think we can do it this way

537.12

is we're going to go to our active tasks

540.32

which is our to-do

543.279

as we see up here so now if we do active

546.839

tasks

551.839

okay so that should work so now if we go

554.24

in here

555.76

and we log out and we log in now it

558.64

brings us to active tasks

560.32

and so home uh is bringing us to login

563.44

so let's take a look at that

568.56

let's see so we want to go to that's our

571.36

internal

574.72

and so home here takes itself slash

578.959

which takes us to home page oh and what

583.12

we want to do here we're just doing a

584.48

redirect

585.12

instead we want to say if we are logged

587.519

in

588.959

which i think we've used that before

595.04

so i may not so we can do it here and

598.08

what we're going to do is we're going to

599.04

say if request

602.88

got user so if we're logged in

608.32

then we're going to redirect to

612.079

the to do

616.64

otherwise and we'll just let it fall

617.92

through otherwise we're gonna redirect

620.16

to the

620.8

login now what this does is this

623.2

basically says hey if i'm logged in

625.44

then i can go one place and if i'm not i

628.32

can go somewhere else

630.48

and this is something we can use

631.839

actually and probably will start

633.519

hooking up in several places

636.56

oh and actually it's not as you i'm

639.279

going to do is

640.36

authenticated and dk

643.36

did and actually what we can do

646.88

is let's just we're going to use this in

648.64

a couple places so if not

652.48

request.user is authenticated so if

654.24

they're not logged in and then in that

655.76

case

658.24

we're going to redirect them to the

659.519

login

662

and otherwise they go to the to do

665.839

and so actually we can do that here to a

667.76

couple of things so like completing a

669.2

task

670.56

let's make sure that they're logged in

675.12

uh show page we have to worry about that

678.8

uh user registration form no creating a

681.36

task let's make sure that they are and

682.959

these are because we're using the

684.279

request.user

686.64

we want to make sure that they're

687.68

validated

689.76

uh let's see don't worry about test mass

692.72

update definitely

699.279

uh edit a task we definitely need to be

701.519

logged in

705.6

listing our tasks listing our road maps

709.44

creating a road map

712.48

and so this is also going to help us in

713.839

several cases where we were

716.079

setting the owner to a request user if

719.12

there is no request user which means

721.04

they're not authenticated

722.399

then we're going to run into some issues

724.8

let's see active tasks

727.04

edit the time frame so we're going to

728.72

start doing this as part

730.079

of our our views

733.279

is we'll just make sure that we are

734.959

authenticated so now

737.76

i've gone through we've done that if i

740.24

do a login

741.12

and now if i do a home it's going to

742.8

come here if i log out

745.12

and i do a home oh actually i can do it

748.399

from here

750

in this case it's going to bring me back

751.12

to login so now it's not going to keep

752.88

kicking me back to log in

754.88

and let's see so i can i'll leave

758.16

well because i'm going to come to home

759.36

i'm going to get rid of to do

761.2

out of my menu items

765.839

so i can get rid of that and that's in

767.839

internal

770.24

so i don't need to worry about that

771.279

anymore

774.56

and now let's continue with our

777.6

application so now

778.72

we're going to come in here we see this

780.56

well if you remember we were working on

782.399

our roadmaps

783.36

so our roadmaps we've got one

786.56

and we could create a new one if we want

788.639

but let's keep with this one so let's

790.16

sort of

790.72

flesh out this road map so this road map

793.36

we've come in we've got a due date

795.12

we have some time frames

798.639

so we've got overall annual goals and

800.56

then we've got

802.32

um first quarter now what we wanted to

804.88

do is we wanted to be able to set a

807.36

a time frame to have uh another time

810.8

frame

811.279

as a parent and so let's go jump into

814.399

that

814.959

um actually let's not this time

818.639

uh so let's go in and uh we're going to

820.72

do because we're going to have a couple

821.68

of things we're going to pick up next

822.8

time

823.44

because we are short this time around so

825.6

then one of the things we want to do

827.519

and we i think we already did it is for

829.04

our overall annual goals we added

831.519

some tasks now we can do that

835.04

also for our quarterly goals

838.639

so i can create for this period let's

841.92

say

842.8

i'm going to create uh application

845.92

version one

849.6

so we'll have a couple of pieces of data

851.44

to work with next time around so create

852.959

application version one

854.24

due date uh march the end of march

858.32

we'll just pick a date towards the end

859.519

of that i'm not going to attach a file

863.6

it's not completed it is new

866.639

uh time frame and this is for the first

869.839

quarter

870.399

now one of the things we see here that

872.88

we're also going to tackle

874.8

is okay so i save that now there's two

877.44

things i came to here from first quarter

880.079

so what i'm going to want to do is use

883.12

that as essentially as a default

885.279

and i want a way to go back as opposed

887.36

to doing this you know back

888.959

which now i got to go back through this

890.32

and then i go back through it

892.56

what i want to do is i'm going to with

894.639

this

896.399

i'm now going to have a way to

898

essentially go back to

899.68

the period that i'm working with so

901.68

that's what we're going to tackle next

902.959

time

903.68

i've gone a little long this time

905.36

playing around with stuff but next time

906.959

what we're going to focus on

909.04

is having some sort of a structure

912.8

within our

913.68

tasks and our roadmap uh goals

917.199

so that we can you know time periods so

919.44

that we can start flushing this thing

920.8

out a little bit

921.68

that'll do it this time around so go out

923.36

there have yourself a great day

925.199

and we will talk to you next time

943.6

you