📺 Develpreneur YouTube Episode

Video + transcript

Learn Python and Django Day 35

2021-02-25 •Youtube

Detailed Notes

We continue cleaning up our master-detail relationships with filtered queries and pre-populating values.

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

Transcript Text
[Music]
well hello and welcome back
today we are continuing uh building out
some of our interface
trying to add to the user experience a
little bit uh it's starting a little
busy we're going to clean this up but
this time first we're going to get some
default values set in
and this is going to be pretty
straightforward so we start from road
maps
if we create a road map we want the
i'm sorry within create a roadmap we
actually want to add
ability to create a time frame
we can create a roadmap so let's add
time frame because we're going to pass
these things down quite a bit
and actually we're going to steal from
the time frame itself so we're going to
steal from edit time frame
time frame edit create time frame we are
going
to steal that guy and we're going to go
back to our roadmap
edit and we're going to give ourselves
oh that's create time frame that's not
what we want we actually wanted to
create i think it's called roadmap
i grabbed the wrong one
let me look at that real quick so if i
come to here
oh that's a time frame oh this is a
so i'm in roadmap
create a roadmap oh i'm sorry so this is
a roadmap i forgot
so now i'm in a roadmap and i want to be
able to create a time frame which is
good
uh let me go back to here that's not
what i wanted
my mistake um but ignore that little
singing thing
so now i am in a road map and when i
want to create a time frame
i want to create it with this road map
annual goals as
uh did i just break that so create time
frame
oh i'm sorry i must have saved that
halfway along
so if i go here
there we go now if i create a time frame
but i want my roadmap to be set
so what i'm going to do is i'm going to
do it simply right now is i'm going to
add some query parameters
which we have done in the past
so here in the roadmap
edit as i come into my list
for each of these when it does a go page
then i want it to be oh i do have that
oh that i'm sorry that's the edit
when i do new i'm going to steal this
here
and i'm going to give myself that id so
now if i look at
tf and actually that may be i think we
already built that in so let's see so
now if i do
create time frame oh i just have not set
it so now
i need to go to the view because i am
sending a
rm value
when i do time frame
whoops
time frame uh this is gonna be
here so if i do edit time frame
when i set my when i pull my data um
did i create a new one here let's see so
oh let's go look at my urls real quick
so if i look at time frames i had
tf does a create time frame so if i look
at create time frame here it is
in this case i'm going to go look for my
variable which is similar to this thing
right here so now what i'm going to do
is come in and say
uh let's see whoa create time frame i
create my blank
right here and then what i'm going to do
is i'm just going to say
is if i've got an rm in there
then i don't know why i called it that
but i'm going to do
a roadmap id
i'm going to get it and then for that
data i'm going to set
its roadmap equal to
roadmap and let's just make this ram uh
let's call it road m
for now okay
so what i'm doing here is i'm going to
set its
parent i assume that's what it is
uh let's see go look oh no that's right
okay so it's going to come through and
now
when i look at it here
uh let's see so from road maps edit so
this should be
if i create a time frame now we're going
to see my annual goals
and boom we see that there
so in the same vein when i come into
my overall annual goals and i see a list
of tiled time frames
when i create a time frame i want it to
be this parent
so i'm going to do essentially the same
thing if i go to
time frame edit now within here if i
create a child
time frame then i'm going to be parent
equals
which is going to p i'm going to be
looking for a variable p
and that's going to be within this it's
going to be
form dot
id
and we'll double check that i think
that's going to get it for us and then
let's see so that's just on the crate i
don't need to do
anything else there i don't think okay
so now i just need to handle the p
in the time frame create oop
and views uh there it is create time
frame so let's take
that same section of code basically
and in here
if it's if i have a get
p
then in this case it's going to be the
parent
and he's going to be a time frame whoop
dot objects.get equals parent id
i missed something oh okay that was just
a typo
and then i want to set the parent for
data
oops
to the parent
pretty straightforward uh we've probably
seen this before
we're just in other applications uh but
this is just sort of clean this stuff
up so now if we go to road maps and i go
here
so that's my annual goals i've got
overall annual goals i've got the first
quarter which if i edit it
he points back to the overall if i go
if i create a time frame here
and so first instead of seeing if it
just exists that way i have to see if
the index exists
so i'm actually going to use this i
think elsewhere
i need to do an n
let's see where else did i use that so
this is
if rm is in there
and that's probably it
yeah because i already did that in a
couple of these other places i just
did not do it correctly okay so fixing
that
save it let's go back here
let's refresh if i do an edit
uh everything's good if i do a create
let's actually inspect this real quick
because i'm not sure that's built right
uh so it's not building this so in child
time frames
let's go look at that in
edit time frame oh i don't think i saved
it
that may be the problem
so let's look at this again this time
i'm getting a p
parent equals a null
which is probably not right oh yes it is
uh so i go here and the problem is
is that parents should be equal to this
not
a null so i want to come in here
and uh it's actually form.id
which is not what i want actually i
think i just called that
did i call that id let's find out real
quick i may have actually sent that in
already
uh if i go to time frame edit
time frame id is that what that is yeah
so it's tfid
just to keep it simple
so i'm just passing it in that way and
now
i should see um my parent is one
uh because this is time frame one so if
i look here
parent equals one and so now if i do
create a time frame for
second quarter then i've got this i
don't have my roadmap yet
so i'm going to create this real quick i
am going to set it as the goals period
is going to be quarterly
and save the record and so now if i go
back to my roadmaps which i'm going to
want to be able to do this a little
differently but if i look at my overall
annual goals now i see first and second
quarter
now what i also want to do is be able to
set the roadmap
so it's going to be the same thing here
and i'm going to do ampersand rm equals
which i think i already used it yep
right here rmid
so i bet i may already have it set up
which would be good so if i go and
create
let's sit this way and do third quarter
goals
uh oh it's not oh
did it not i may not have set the value
right so let's go look at this again
let's look at this again uh let's see
so child time frames
oh that's create time frame which is
good yeah which is good
uh ampersand rmi rm equals
rmid
so maybe the roadmap's not coming
through right that may be the problem
yes i don't have
rmid passed into here for some reason
so let's see where i did
so there's rmid equals that that's with
edit a road map
oh that's easy enough to fix so if i
come into create
then uh let's see let's create time
frame time frame edit
uh yes oops
so let's edit i'm sorry there's edit
time frame
okay time frame so he probably wants to
send the same thing
actually
so if i send all of that in
well i really don't need all of that
so let's like let's get rid of that my
mistake
so let's go in here and we need to do we
do need um
am i not calling create time frame one
second while i'm looking at this i've
been doing tf
edit if i do tf with the create
let's make sure what i'm doing here uh
so if i do create time frame here
he's just doing a tf
so he should be hitting it at yes so
okay so i changed the wrong code i think
let's see
uh 299 and create frame so if we go here
299.
so it is in create oh no i'm good i'm
good except i'm not passing all that
stuff
in
so i'm building all this stuff out
well but i don't need children
but i do need
oh because i'm doing that a little bit
differently so i probably don't need all
of those so i can actually come in here
uh let's take a look at this real quick
pid rid
oh it's already an ant
so i don't need that i don't need that
let's keep this guy the same
as he was
let's see i think that'll work
let's try that it's probably something
undefined variable
task nope and roadmap good good good
id expected a number but got blank so
when i do the r i'm getting up oh my
road map's coming back
blank so if i go back here
oh i have to go all the way up i think
roadmap there
so he has roadmap id if i do create time
frame
he's not sending that in right so it
should be rm equals one
should sit there oh because i'm not
that's right when i come down here
so i have an rm but i need to have
uh what did i call that so we're gonna
come in here now
we set our roadmap id uh annual goals
got uh overall annual goals for to
create time frame
and now we have overall annual goals and
annual goals so we've set everything up
and we are off and running so
now we've got some of our basics the
next thing we want to do is we'll come
back around next time and
for our task we're going to go ahead and
pass down our time frame
but we've run out of time this time dug
through stuff a little bit next time
we're going to
quickly uh probably kind of swing
through that and we're going to clean up
a couple of things as well and then
continue moving forward so as always
you can check out the latest we are up
today this will be
tagged for day 35 and you can grab that
out of github take a look at the source
and as always go out there have yourself
a great day and we will talk to you
next time
you
Transcript Segments
0.63

[Music]

26.72

well hello and welcome back

28.64

today we are continuing uh building out

31.039

some of our interface

32

trying to add to the user experience a

33.52

little bit uh it's starting a little

34.96

busy we're going to clean this up but

36.719

this time first we're going to get some

39.6

default values set in

41.44

and this is going to be pretty

42.239

straightforward so we start from road

43.92

maps

45.36

if we create a road map we want the

49.2

i'm sorry within create a roadmap we

51.36

actually want to add

52.719

ability to create a time frame

55.76

we can create a roadmap so let's add

57.52

time frame because we're going to pass

58.719

these things down quite a bit

61.68

and actually we're going to steal from

63.84

the time frame itself so we're going to

65.199

steal from edit time frame

68.96

time frame edit create time frame we are

71.68

going

72

to steal that guy and we're going to go

75.52

back to our roadmap

76.72

edit and we're going to give ourselves

83.6

oh that's create time frame that's not

85.28

what we want we actually wanted to

86.72

create i think it's called roadmap

90.479

i grabbed the wrong one

94.079

let me look at that real quick so if i

95.68

come to here

98.799

oh that's a time frame oh this is a

102

so i'm in roadmap

105.119

create a roadmap oh i'm sorry so this is

107.92

a roadmap i forgot

109.04

so now i'm in a roadmap and i want to be

110.64

able to create a time frame which is

112.079

good

112.96

uh let me go back to here that's not

114.96

what i wanted

117.92

my mistake um but ignore that little

121.2

singing thing

122.24

so now i am in a road map and when i

124.719

want to create a time frame

126.479

i want to create it with this road map

128.319

annual goals as

130.8

uh did i just break that so create time

133.04

frame

137.36

oh i'm sorry i must have saved that

139.76

halfway along

140.64

so if i go here

144.4

there we go now if i create a time frame

145.92

but i want my roadmap to be set

149.2

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

150.16

do it simply right now is i'm going to

151.92

add some query parameters

153.76

which we have done in the past

156.8

so here in the roadmap

160

edit as i come into my list

163.36

for each of these when it does a go page

168

then i want it to be oh i do have that

170.08

oh that i'm sorry that's the edit

172.8

when i do new i'm going to steal this

177.36

here

181.68

and i'm going to give myself that id so

183.44

now if i look at

185.2

tf and actually that may be i think we

187.12

already built that in so let's see so

188.8

now if i do

189.68

create time frame oh i just have not set

192.08

it so now

194.4

i need to go to the view because i am

196.4

sending a

197.519

rm value

201.28

when i do time frame

207.599

whoops

210.799

time frame uh this is gonna be

216.799

here so if i do edit time frame

219.92

when i set my when i pull my data um

223.599

did i create a new one here let's see so

226.319

oh let's go look at my urls real quick

228.239

so if i look at time frames i had

232

tf does a create time frame so if i look

234.879

at create time frame here it is

237.12

in this case i'm going to go look for my

241.12

variable which is similar to this thing

245.04

right here so now what i'm going to do

246.319

is come in and say

248.08

uh let's see whoa create time frame i

251.2

create my blank

252.239

right here and then what i'm going to do

254.72

is i'm just going to say

255.68

is if i've got an rm in there

259.359

then i don't know why i called it that

262.079

but i'm going to do

262.88

a roadmap id

266

i'm going to get it and then for that

268

data i'm going to set

269.759

its roadmap equal to

272.96

roadmap and let's just make this ram uh

278.639

let's call it road m

282.639

for now okay

286.479

so what i'm doing here is i'm going to

289.199

set its

290.479

parent i assume that's what it is

295.36

uh let's see go look oh no that's right

297.44

okay so it's going to come through and

298.8

now

300.72

when i look at it here

304

uh let's see so from road maps edit so

307.039

this should be

307.84

if i create a time frame now we're going

310.08

to see my annual goals

311.84

and boom we see that there

314.88

so in the same vein when i come into

318.72

my overall annual goals and i see a list

320.8

of tiled time frames

322.72

when i create a time frame i want it to

324.479

be this parent

327.44

so i'm going to do essentially the same

329.44

thing if i go to

330.56

time frame edit now within here if i

334.24

create a child

335.12

time frame then i'm going to be parent

338.479

equals

340.24

which is going to p i'm going to be

341.52

looking for a variable p

343.44

and that's going to be within this it's

346.56

going to be

348.24

form dot

351.28

id

355.039

and we'll double check that i think

356.16

that's going to get it for us and then

358.08

let's see so that's just on the crate i

359.52

don't need to do

364

anything else there i don't think okay

366.08

so now i just need to handle the p

368.08

in the time frame create oop

371.12

and views uh there it is create time

373.68

frame so let's take

375.12

that same section of code basically

382.96

and in here

386.08

if it's if i have a get

392.84

p

396.88

then in this case it's going to be the

399.199

parent

402.639

and he's going to be a time frame whoop

407.6

dot objects.get equals parent id

413.36

i missed something oh okay that was just

415.599

a typo

416.56

and then i want to set the parent for

418.8

data

420.84

oops

423.68

to the parent

427.199

pretty straightforward uh we've probably

429.759

seen this before

430.639

we're just in other applications uh but

433.84

this is just sort of clean this stuff

435.36

up so now if we go to road maps and i go

438.24

here

438.72

so that's my annual goals i've got

440.08

overall annual goals i've got the first

442.08

quarter which if i edit it

444

he points back to the overall if i go

447.599

if i create a time frame here

452.24

and so first instead of seeing if it

454.4

just exists that way i have to see if

457.199

the index exists

460.639

so i'm actually going to use this i

462.16

think elsewhere

464.24

i need to do an n

468.72

let's see where else did i use that so

470.879

this is

476.319

if rm is in there

481.68

and that's probably it

485.52

yeah because i already did that in a

486.72

couple of these other places i just

488.8

did not do it correctly okay so fixing

492.24

that

493.599

save it let's go back here

497.52

let's refresh if i do an edit

501.039

uh everything's good if i do a create

503.919

let's actually inspect this real quick

505.36

because i'm not sure that's built right

507.759

uh so it's not building this so in child

509.84

time frames

511.12

let's go look at that in

515.12

edit time frame oh i don't think i saved

518.08

it

518.959

that may be the problem

522.399

so let's look at this again this time

525.04

i'm getting a p

525.839

parent equals a null

529.04

which is probably not right oh yes it is

532.56

uh so i go here and the problem is

536.64

is that parents should be equal to this

538.48

not

539.76

a null so i want to come in here

542.88

and uh it's actually form.id

546.16

which is not what i want actually i

549.279

think i just called that

553.76

did i call that id let's find out real

555.44

quick i may have actually sent that in

556.8

already

557.36

uh if i go to time frame edit

562.88

time frame id is that what that is yeah

564.8

so it's tfid

566.08

just to keep it simple

571.6

so i'm just passing it in that way and

574.839

now

576.32

i should see um my parent is one

580.32

uh because this is time frame one so if

583.519

i look here

585.279

parent equals one and so now if i do

587.68

create a time frame for

588.959

second quarter then i've got this i

591.2

don't have my roadmap yet

595.76

so i'm going to create this real quick i

598.88

am going to set it as the goals period

601.44

is going to be quarterly

604

and save the record and so now if i go

607.12

back to my roadmaps which i'm going to

608.32

want to be able to do this a little

609.92

differently but if i look at my overall

612.24

annual goals now i see first and second

613.76

quarter

614.32

now what i also want to do is be able to

617.04

set the roadmap

618.399

so it's going to be the same thing here

623.44

and i'm going to do ampersand rm equals

628.079

which i think i already used it yep

629.76

right here rmid

635.2

so i bet i may already have it set up

637.279

which would be good so if i go and

638.959

create

640.32

let's sit this way and do third quarter

642

goals

644.839

uh oh it's not oh

648.399

did it not i may not have set the value

650.64

right so let's go look at this again

654.959

let's look at this again uh let's see

658.839

so child time frames

663.839

oh that's create time frame which is

665.92

good yeah which is good

667.68

uh ampersand rmi rm equals

672.839

rmid

675.839

so maybe the roadmap's not coming

677.12

through right that may be the problem

681.839

yes i don't have

685.279

rmid passed into here for some reason

695.36

so let's see where i did

698.48

so there's rmid equals that that's with

701.839

edit a road map

706.8

oh that's easy enough to fix so if i

708.64

come into create

710.079

then uh let's see let's create time

712.8

frame time frame edit

720.88

uh yes oops

724.16

so let's edit i'm sorry there's edit

725.68

time frame

728.16

okay time frame so he probably wants to

731.279

send the same thing

742.839

actually

745.76

so if i send all of that in

751.04

well i really don't need all of that

755.76

so let's like let's get rid of that my

758.8

mistake

759.44

so let's go in here and we need to do we

761.44

do need um

765.68

am i not calling create time frame one

767.519

second while i'm looking at this i've

768.72

been doing tf

770.079

edit if i do tf with the create

778.079

let's make sure what i'm doing here uh

780.959

so if i do create time frame here

784.16

he's just doing a tf

787.36

so he should be hitting it at yes so

790.639

okay so i changed the wrong code i think

793.12

let's see

793.839

uh 299 and create frame so if we go here

797.2

299.

798.8

so it is in create oh no i'm good i'm

800.639

good except i'm not passing all that

802.56

stuff

802.959

in

809.44

so i'm building all this stuff out

812.56

well but i don't need children

820.32

but i do need

826.72

oh because i'm doing that a little bit

828.16

differently so i probably don't need all

830

of those so i can actually come in here

836.8

uh let's take a look at this real quick

840.399

pid rid

850.72

oh it's already an ant

859.279

so i don't need that i don't need that

864.959

let's keep this guy the same

868.8

as he was

875.279

let's see i think that'll work

879.76

let's try that it's probably something

882.959

undefined variable

884

task nope and roadmap good good good

890.959

id expected a number but got blank so

894.639

when i do the r i'm getting up oh my

897.36

road map's coming back

898.639

blank so if i go back here

903.04

oh i have to go all the way up i think

906.079

roadmap there

909.68

so he has roadmap id if i do create time

912

frame

914.56

he's not sending that in right so it

916.24

should be rm equals one

919.199

should sit there oh because i'm not

923.04

that's right when i come down here

930.959

so i have an rm but i need to have

935.12

uh what did i call that so we're gonna

937.68

come in here now

938.959

we set our roadmap id uh annual goals

944.24

got uh overall annual goals for to

947.12

create time frame

948.399

and now we have overall annual goals and

950.32

annual goals so we've set everything up

952.56

and we are off and running so

956.399

now we've got some of our basics the

958.56

next thing we want to do is we'll come

959.6

back around next time and

961.04

for our task we're going to go ahead and

963.44

pass down our time frame

965.04

but we've run out of time this time dug

967.759

through stuff a little bit next time

968.88

we're going to

969.44

quickly uh probably kind of swing

971.199

through that and we're going to clean up

972.959

a couple of things as well and then

974.639

continue moving forward so as always

978.32

you can check out the latest we are up

980.399

today this will be

981.759

tagged for day 35 and you can grab that

984.88

out of github take a look at the source

986.88

and as always go out there have yourself

988.8

a great day and we will talk to you

991.6

next time

1008

you