📺 Develpreneur YouTube Episode

Video + transcript

Learn Python and Django Day 34

2021-02-23 •Youtube

Detailed Notes

We build out some master-detail form links as we improve the user experience for our application.

You can view source for today and all prior days by reviewing the tag Day 34 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
hello and welcome back
we are continuing digging into our
application getting a little deeper into
the django and python world
this time around we're going to look at
cleaning stuff up a little bit
and we're going to look at our road maps
if you remember last time around
we have these high level time frames
right for example annual goals but what
we'd like to do is make it so that we
can make
children out of the higher level
so we could have anal goals and then
have you know quarters with under
under that months under that now what we
want to do
is let's take a look at our model
because one of the things we have to do
with our time frame
as we talked about is we have to create
a parent
so we're going to go in and create a
we've done this
done our migration so we now have uh
within
like if i look at
my database
figure out what i to remind myself what
i set this up
as
i set it up as uh
root and with that is the password
and so now if i use dp project
if i look at the time frame
there you go that one then i can see
i've got my parent id
and if we look here and we edit
uh for example first quarter then i can
set a parent
which i have done to overall goals but
now i need to be able to actually
display this
in some way so if i go back to my time
frames if i look at annual goals
right now it's actually not doing
anything because i need to walk through
it has to have a road map it's looking
for road map associated with it so i've
sort of blown up my time frames list
because now i'm going to want to go
through here so let's get rid of time
frames off of navigation
and if we go to probably it's in base
somewhere down here
oh is that the right base that is the
right base let's try
oh we called it internal
so let's get time rid of time frames
because we're going to actually
access them through our roadmaps and now
what we want to do
is we want to as we go in we want to
within a road map one of the things
we're going to do which we've seen
is we're tying the road map well we also
well first let's clean this list up so
this
is this list of time frames we need
everybody that does not have
a parent so uh
let's go into our roadmap list
oh actually we need to go into our view
and
when we look at our roadmap list
roadmaps we want here
except for all we're going to do get
where parent and i think we called it
parent
yeah actually i think we call it parent
let's try that should we
probably do parent id but let's try
let's see
oh okay so it's not parent so if we go
to a row oh i'm sorry it's not roadmap
objects
it's not roadmap it is
uh let's see that's all that's road maps
but i want uh let's list road maps when
i do an edit uh sorry view roadmap
i'm gonna have a list let's look at that
here's edit
roadmap so within roadmap
i have here we go time frames where
roadmap is equal to the data
and i want where parent
goes no let's see if that works for us
and i think we're running we are we're
updated
and if we reload that oh i'm sorry it's
not it's not i want
it to about it evaluates uh let's see so
back to views
it's actually is null
and i want to filter where is null
equals
true
because if it's then that's going to
give me a top level
and so now i'm going to see only my
overall annual goals now what i need
when i step into here
is i need child time frames so within a
time frame
i'm now going to uh if i look at edit
time frame
go to edit time frame i now need we're
going to call it
children
and that is going to be a time frame
dot objects
that filter where
parent equals this
and parent is going to be uh let's see
time frame where did i get the id data
timeframe data yes so data
and then i need to
send this
and so now uh we're gonna do this this
way so we've got a parent and we've also
got
a road map which is gonna be a little
different so
so we're going to add one more which is
going to be
let's see do we need to chill we
probably
don't really need to send that
okay so parent will be roadmap we can do
this we can work with this it's gonna be
a little bit confusing well let's do
that let's change this to
roadmap and
parent is going to be roadmap
because now we're going to have a
roadmap that you belong to but your
parent could be a time frame or a null
so let's see parent
roadmap
roadmap
roadmap is a roadmap
uh that gives me now road map of
children so now i'm going to go to time
frame edit
the first thing i do is that parent id
is actually roadmap id
roman name uh let's see do i have parent
elsewhere
that's if road map
and then i need to do the same thing for
my parent so
i do the same thing here as i'm just
going to do if
parent
actually if it's actually this it's if
who am i i am form
is that what i call it let's make sure
we got that right let's go to views
i send form i did not send data so i
think i can just do form.parent
uh let's see where did that go if oh
it formed out parent
and this is gonna be i think i called it
time frame or tf
let's go look here yeah tf
and that's going to be form
dot parent i id let's
keep that simpler i'm going to actually
send i am going to send the parent in
so i'm not having to play around with
that too much
go page tf blah blah blah so let's go
back here and let's just make this
parent is actually pretty easy because
it's just going to be data dot
parent whoops
that parent
and notice we're getting a little bit
long we could change this stuff around a
little bit
and simplify it uh we could send some
stuff we could actually store some stuff
like the
map for example we might want to at some
point restore stored as a session
variable or something along those lines
just so we're not passing stuff around
but for now
let's see that goes there we're going to
keep it as is
and we go back to our time frame edit
so we get that uh and now we have
children
so this is gonna be
we're gonna call this um we're gonna get
a couple of br's here
split up a little bit and this is gonna
be create
time period period
which i think we just call that tf and
we'll clean that up a little bit later
we're going to do this
this is uh
we will call this uh let's call this
child time frames
for now and we're going to basically
steal this
and put it right under here and we're
going to say if children
we can probably steal from so this is a
time frame list let's go back to the
road map edit and let's do it this way
let's steal
this one
actually we can steal that whole thing
let's go back here and that's going to
be child time frames
and then all i need to do is if instead
of if whoops instead of
time frames it's going to be if children
and then for tf and children
no child time frames
and now we're gonna be able to go to
road maps
go to annual goals and we're gonna see
uh
did we not say oh we're gonna go to
annual goals within the road map
and then we can see child time frames
we're gonna see first quarter
it has no children tile frank child time
frames
but it does have some tasks underneath
it
and if we go back here i think one of
the things we want to do which is where
it may be useful to set
a a session variable is for example this
time frame
overall annual goals is good it comes up
with nothing but if i create time frame
what i would like
is for parent to be oh and it's not
doing it right now so when i do create
time frame
oh i did not give my slash um
so i'm going to actually go here
and let's just reload that and go to
create time frame
and so i would like my rode my parent
and my roadmap
to get preset and that is what we're
going to look at
next time around so i hope you enjoyed
this we will continue digging into this
a little bit further moving a little
you know moving the ball forward on our
application as always go out there have
yourself a great day
and we will talk to you next time
you
Transcript Segments
0.93

[Music]

26.24

hello and welcome back

27.68

we are continuing digging into our

29.76

application getting a little deeper into

31.519

the django and python world

33.68

this time around we're going to look at

35.92

cleaning stuff up a little bit

37.44

and we're going to look at our road maps

39.28

if you remember last time around

40.96

we have these high level time frames

44.079

right for example annual goals but what

46

we'd like to do is make it so that we

47.76

can make

48.32

children out of the higher level

51.36

so we could have anal goals and then

52.879

have you know quarters with under

54.559

under that months under that now what we

57.76

want to do

58.399

is let's take a look at our model

62.399

because one of the things we have to do

63.76

with our time frame

65.6

as we talked about is we have to create

67.84

a parent

69.52

so we're going to go in and create a

71.84

we've done this

72.88

done our migration so we now have uh

75.759

within

77.2

like if i look at

80.96

my database

86.08

figure out what i to remind myself what

88.08

i set this up

89.119

as

92.24

i set it up as uh

95.439

root and with that is the password

103.2

and so now if i use dp project

108.88

if i look at the time frame

125.04

there you go that one then i can see

127.439

i've got my parent id

128.56

and if we look here and we edit

132.8

uh for example first quarter then i can

135.76

set a parent

136.879

which i have done to overall goals but

138.8

now i need to be able to actually

140.08

display this

141.28

in some way so if i go back to my time

143.52

frames if i look at annual goals

146.879

right now it's actually not doing

148

anything because i need to walk through

151.04

it has to have a road map it's looking

153.36

for road map associated with it so i've

154.959

sort of blown up my time frames list

157.44

because now i'm going to want to go

158.48

through here so let's get rid of time

159.84

frames off of navigation

163.2

and if we go to probably it's in base

168.239

somewhere down here

171.28

oh is that the right base that is the

173.12

right base let's try

174.4

oh we called it internal

178

so let's get time rid of time frames

179.599

because we're going to actually

181.2

access them through our roadmaps and now

183.44

what we want to do

184.56

is we want to as we go in we want to

189.04

within a road map one of the things

191.519

we're going to do which we've seen

192.8

is we're tying the road map well we also

198

well first let's clean this list up so

200.8

this

201.12

is this list of time frames we need

203.36

everybody that does not have

205.84

a parent so uh

209.36

let's go into our roadmap list

212.56

oh actually we need to go into our view

215.44

and

217.68

when we look at our roadmap list

219.36

roadmaps we want here

222.4

except for all we're going to do get

225.519

where parent and i think we called it

228.239

parent

228.879

yeah actually i think we call it parent

236.72

let's try that should we

240.08

probably do parent id but let's try

242.48

let's see

243.36

oh okay so it's not parent so if we go

245.599

to a row oh i'm sorry it's not roadmap

247.2

objects

249.12

it's not roadmap it is

253.12

uh let's see that's all that's road maps

257.359

but i want uh let's list road maps when

261.12

i do an edit uh sorry view roadmap

263.52

i'm gonna have a list let's look at that

266.4

here's edit

267.199

roadmap so within roadmap

270.32

i have here we go time frames where

272.88

roadmap is equal to the data

275.44

and i want where parent

279.52

goes no let's see if that works for us

283.52

and i think we're running we are we're

285.44

updated

287.36

and if we reload that oh i'm sorry it's

290.72

not it's not i want

291.919

it to about it evaluates uh let's see so

294.88

back to views

295.68

it's actually is null

299.6

and i want to filter where is null

302.24

equals

303.039

true

306.32

because if it's then that's going to

307.919

give me a top level

310.8

and so now i'm going to see only my

312.32

overall annual goals now what i need

314

when i step into here

316.08

is i need child time frames so within a

320.16

time frame

322.88

i'm now going to uh if i look at edit

327.039

time frame

334

go to edit time frame i now need we're

337.039

going to call it

338.4

children

342

and that is going to be a time frame

345.44

dot objects

349.759

that filter where

352.8

parent equals this

359.039

and parent is going to be uh let's see

362.08

time frame where did i get the id data

365.84

timeframe data yes so data

371.759

and then i need to

375.84

send this

380.88

and so now uh we're gonna do this this

383.68

way so we've got a parent and we've also

385.6

got

386

a road map which is gonna be a little

387.44

different so

396.16

so we're going to add one more which is

398.479

going to be

400.56

let's see do we need to chill we

403.6

probably

404.08

don't really need to send that

408.72

okay so parent will be roadmap we can do

410.24

this we can work with this it's gonna be

411.84

a little bit confusing well let's do

413.36

that let's change this to

417.039

roadmap and

420.4

parent is going to be roadmap

424.319

because now we're going to have a

425.36

roadmap that you belong to but your

426.639

parent could be a time frame or a null

429.36

so let's see parent

437.36

roadmap

441.599

roadmap

444.8

roadmap is a roadmap

450.08

uh that gives me now road map of

451.68

children so now i'm going to go to time

452.8

frame edit

455.68

the first thing i do is that parent id

457.68

is actually roadmap id

467.84

roman name uh let's see do i have parent

470.72

elsewhere

473.199

that's if road map

478.72

and then i need to do the same thing for

480.16

my parent so

482.96

i do the same thing here as i'm just

484.639

going to do if

486

parent

489.52

actually if it's actually this it's if

493.039

who am i i am form

497.52

is that what i call it let's make sure

498.879

we got that right let's go to views

501.84

i send form i did not send data so i

504.4

think i can just do form.parent

509.36

uh let's see where did that go if oh

512.479

it formed out parent

516.959

and this is gonna be i think i called it

521.039

time frame or tf

524.159

let's go look here yeah tf

528.32

and that's going to be form

533.12

dot parent i id let's

536.399

keep that simpler i'm going to actually

538.64

send i am going to send the parent in

543.279

so i'm not having to play around with

544.64

that too much

549.76

go page tf blah blah blah so let's go

552

back here and let's just make this

555.44

parent is actually pretty easy because

557.04

it's just going to be data dot

558.56

parent whoops

562.56

that parent

566.64

and notice we're getting a little bit

567.839

long we could change this stuff around a

569.279

little bit

569.92

and simplify it uh we could send some

572.72

stuff we could actually store some stuff

574.399

like the

575.12

map for example we might want to at some

576.8

point restore stored as a session

578.48

variable or something along those lines

580.32

just so we're not passing stuff around

582.72

but for now

584.48

let's see that goes there we're going to

585.92

keep it as is

588.88

and we go back to our time frame edit

591.92

so we get that uh and now we have

594.88

children

595.6

so this is gonna be

600.48

we're gonna call this um we're gonna get

603.68

a couple of br's here

606.16

split up a little bit and this is gonna

608.64

be create

611.68

time period period

620.48

which i think we just call that tf and

623.04

we'll clean that up a little bit later

624.32

we're going to do this

625.44

this is uh

630

we will call this uh let's call this

633.12

child time frames

637.2

for now and we're going to basically

640.959

steal this

644.399

and put it right under here and we're

645.839

going to say if children

652.079

we can probably steal from so this is a

654.079

time frame list let's go back to the

656

road map edit and let's do it this way

659.839

let's steal

660.56

this one

664.079

actually we can steal that whole thing

668.079

let's go back here and that's going to

670.16

be child time frames

677.76

and then all i need to do is if instead

679.76

of if whoops instead of

681.6

time frames it's going to be if children

686.079

and then for tf and children

694.079

no child time frames

699.519

and now we're gonna be able to go to

702.32

road maps

703.519

go to annual goals and we're gonna see

706

uh

706.56

did we not say oh we're gonna go to

709.519

annual goals within the road map

711.839

and then we can see child time frames

713.519

we're gonna see first quarter

714.88

it has no children tile frank child time

717.76

frames

718.8

but it does have some tasks underneath

721.36

it

722.959

and if we go back here i think one of

725.04

the things we want to do which is where

726.399

it may be useful to set

727.76

a a session variable is for example this

731.839

time frame

732.88

overall annual goals is good it comes up

735.92

with nothing but if i create time frame

737.839

what i would like

738.639

is for parent to be oh and it's not

741.76

doing it right now so when i do create

743.44

time frame

745.519

oh i did not give my slash um

750.48

so i'm going to actually go here

756.639

and let's just reload that and go to

758.72

create time frame

759.76

and so i would like my rode my parent

762.959

and my roadmap

764

to get preset and that is what we're

766.639

going to look at

767.6

next time around so i hope you enjoyed

769.44

this we will continue digging into this

771.68

a little bit further moving a little

773.04

you know moving the ball forward on our

774.48

application as always go out there have

776.72

yourself a great day

777.92

and we will talk to you next time

796

you