📺 Develpreneur YouTube Episode

Video + transcript

Learn Python and Django Day 30

2021-02-09 •Youtube

Detailed Notes

We continue creating roadmap features with basic updates and a model change.

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

Transcript Text
well hello and welcome back
we are continuing our uh python and
django series of sessions
and uh we last time we we discussed
the uh the road map we added a road map
and a time frame
we have the ability to list and edit
road maps
so we're going to start working on the
time frame now one thing we're going to
adjust here we've got a
couple things we're going to do is uh a
time frame
is actually going to be tied to a
roadmap it's not going to tie
a task necessarily to
it's it's not going to be a direct link
there because we'll have a single time
frame
for example annual that would have
multiple tasks related to it and this is
uh a little bit to just help us in how
we're going to do this from a user
experience point of view
and that being that we're going to come
in and we're going to create a roadmap
as a user you'll create a roadmap
you can pull in time frames you'll
create a time frame
and then you're going to assign tasks to
the time frame
so here we're going to take
and actually what we're going to do to
make it really simple is we're now
going to say that every task is going to
need
a time frame and so we will come in
and do let's see we're just gonna call
him
uh because we don't have anything here
so we're gonna call we're gonna let me
uh
let's just pick like here copy this
because now a task will have a time
frame
and it's going to have a foreign key to
time frame
and the verbose name is going to be
time frame oops i'm going to do it this
way
so now we're going to be able to do that
and i do want to do
uh as we've seen before here we go so
you can have a null
and a blank and we're going to allow
that uh
technically we're probably not going to
have that so but
i guess we could we could have tests
that are not tied to time frames
so what we'll do is we'll come in we'll
create road maps we'll create a time
frame
and then we'll be able to uh once that's
done
we'll be able to tie tasks uh to a time
frame
and so we're gonna see uh lookups and
things like that through all of these so
we've changed our model
uh one of the things we're going to have
to do and let's start with
our forms so road map form
we're good but task form
is now going to have
the time frame whoops which again
i need to do it like that
and uh we need to create
for our model over here we need to
create
a form for our time frame
so we don't have one so let's do
i'll keep this so i can keep up with
what i need to deal with for my time
frame and i'm just going to replicate
this rather quickly
and this is not the roadmap form this is
going to be my time frame form
and the model is going to be models dot
time isn't going to kick it nope it's
not going to give me the auto complete
so it's going to be uh
models.time frame and the fields are
going to be
a little different here because we still
have a name
but we also have a roadmap
and a time frame
oh which is the time frame in itself
let's change that
to period instead
and he's going to be time frame actually
we'll just go ahead and change the whole
thing
so that's going to be period choices
oops i'm going to change that over
another one my mistake so we're going to
call him period instead of time frame
and we're going to start with something
moderately simple here let's say we
don't have a hidden input
and we're not using dates or anything
like that but we will keep the name
uh we're gonna have that so that's
standard size
so now let's uh so that should be our
time frame
form now let's go back over here and
we're gonna change that period so we're
gonna actually
do a little bit of tweaking here but
we're gonna see this when we
update when we do our migrations
we're going to see this stuff get
cleaned up for us we're going to rename
this to period
and let's see task is done there so we
got our task form
updated uh so let's see so
roadmap task oh
um oh we've got roadmap here so we have
those
we have let's group these a little bit
so we're going to group our task related
stuff
group our roadmap related stuff
and now we're basically going to have
those same things
i'll keep it somewhat similar and this
is going to be for a time frame
but we're just going to use tf as the
abbreviation for the url just to keep it
a little bit simpler
and we're going to be able to create a
time frame
uh list time frames
time frames
and edit time frame
so we've got those three create list and
edit and we're going to come over to
views wherever that went there we go
and let's see so if we can maybe steal
these create
lists
and well we'll start we'll push this to
the bottom
and we also need create tasks so where
is create there it is
and we're not going to bother with our
delete yet
so each of these was time frame
and let's just copy and paste that name
so we can get that done right so we're
going to take him there we're going to
edit it
we're going to list it and we're going
to create it
and i think i had an s at the end of
this if i look back over here where did
i put that
on my urls i had
list time frames okay so that's good so
that's multiple
and now uh again we're going to fairly
quickly be able to fly through these
things and make our changes so
that was actually it's the time frame
object let's make sure
yep i already got that upstairs upstairs
up at the top of the page
so let's jump back to the bottom and
let's see i don't really need to worry
about an owner because
they don't exist in this case this is no
longer the time frame for
task form it's the time frame form we'll
keep that the same
let's see we don't really have to worry
about delete i will leave it in there
even though we're not actually going to
uh well i guess we can we could take it
through here so uh let's see so we're
gonna do that that's our id
record deleted he's gonna go instead to
tfs
again this is a time frame form whoops
and we use this instance data form form
form save redirect to tfs
yen valid record good edit time frame
form title message and it's going to do
to
time frame edit because we're going to
and we'll have to make that so
task edit we're just duplicate that
and we're going to call him or her if
you want to be
picky about it time frame edit
and we're also going to need uh task
list is going to become
time frame list
so we had our two tasks we have our time
frame so we're getting ourselves
somewhat going here and they'll look
somewhat similar because we are
this makes it a little easier because
we're sort of staying the same
as far as some of our parameters that
are going in
uh here let's see so we do like list
we have titles and tasks we could keep
that but we're gonna we'll clean that up
a little bit
just for uh user's sake but if we wanted
we could call this items or something
like that
and then or i'm sorry this part the
variable would be items
we're just gonna pass different items in
and we could probably use actually the
same
form for the most part um especially for
the listing
especially because everybody's got a
name there's some ways we can do this
that we could make it
really easy to limit our code and not
have to reproduce stuff almost
almost at all so this could be all
time frames because we are getting all
of them
we're just going to call this tfs time
frames and this is going to be tfs
time frames because i don't feel like
typing as much
and um let's just call this frame
uh no because framework it won't like
that so we're going to call this we'll
just keep it
time frames and this is going to go to
time frame list
create a time frame we're going to clean
this up here
it's going to be a time frame form and
create new record create a time frame
time frame form
come in let's see invalid record blah
blah blah blah blah blah blah time frame
edit
and so we've cranked those out real
quick and so let's go look at our time
frame edit
uh let's see it's actually in pretty
good
shape uh there's nothing we have to do
specific there
so it actually could be
we could actually send it to task edit
so we could do like generic edit
send it there but we're not going to do
that right now
um let's see and then so oh timeframe
list
so now this one's where we're going to
deal with this a little bit because
uh so complete task doesn't really
matter for a task
and yeah let's get rid of that for now
uh and it wasn't
tasks it's time frames
and for uh we'll just call it tf
so time frame in time frames
and then there's gonna be a class um
let's call it time frame
uh this is gonna be a css style so we
had a task uh let's
fix that real quick so we had tasks
and this is going to be
[Music]
oh sorry control c control v
and then we're just gonna call it time
frame
for now we're going to leave it the same
as a task but we're going to come back
and make some changes to it at some
point so
let's go back to our time frame edit
did we oh shoot that was the wrong page
it's probably not going to like me let's
see if i can get back over here
let's see
three two one
so let's make sure we save this when we
do our edit
we can go to our list
and let's go back here so we have a time
frame it's going to be
instead we're going to give it an id of
tf underscore
it's going to be tfid the name is going
to be the
time frame name we don't need to have a
due date
actually most of this stuff i don't
think we're going to have let's get rid
of our break there we don't need a
status we don't need a time
we do want an edit
and we don't need a complete
and so it's gonna go to uh time frame
and it's gonna be time frame id no time
frames
available
and so that's going to give us our
uh listing let's see i think
we'll do a file save all so let's go
play around and see if we can do our
whoops
let's see uh well that's right that one
works i want to do my
make migrations because we made some
changes to the model
uh timeframe is not defined so i missed
something somewhere in models line 21.
okay
oh this may be a issue that we have
so line 21 time frame has not been
created yet
so uh
because this is gonna go top to bottom i
don't know if we've mentioned this
before
you can't add something that refers
to something that's defined later in the
file
so this time frame that we refer to has
to already be created
so if we do that let's see if that works
for us
time frame choice oops i didn't change
my
when i changed it i didn't get
everything's changed properly
period choice oh this needs to be
period choices
and i think that will do it
so now we make migrations uh let's see i
know field time frames testify for task
so let's take a look at that
time frame time frame got it
oh let's see what am i complaining about
here it's probably somewhere else so if
i go to
oh forms
line 28 so there's something wrong there
so let's go
to our forms 28 there's a task form
oh i bet
task form is time frame let's see what i
complain about
let's look again it said that
let's see unknown field time frame
specified for task so if we go look at
task
uh in our models where's our models
there's our models
time frame lowercase um that's the
verbose name so the actual one is
lowercase is how we're gonna
list uh access it where did i go to my
forms
so here that's not capital t it's
lowercase t
time frame
hopefully that got all the things right
let's see
so did you rename that to period yes
because we did rename it
and so now we can do migrate
and so now we should be able to run it
and if we go to our link over here and
log in then we can see things like
uh let's see i think roadmap we had so
we could go in and we can edit a roadmap
now what we don't have is a time frame
so we're just going to call it uh tfs
to get us that time frame list
uh and so it's going to say cannot
resolve due date oh i've got something
left over here
oh there we go i've got an order by so
i've got to go fix that
and so if i go to view i had
an order by in list
so it's order by name
and that probably will fix it and there
we go no time frames available
so we covered a lot of ground
i'm going to call it a a session right
now
and um we will come back around next
time
and we're going to get a little deeper
into hooking our tasks and time frames
and road maps together so
as always uh thanks for listening we do
have you'll see this tag
day 30 on our github as far as the code
that i'm gonna
that we've looked at today and then as
always go out there have stuff a great
day
and we will talk to you next time
Transcript Segments
0.88

well hello and welcome back

3.04

we are continuing our uh python and

6

django series of sessions

8.639

and uh we last time we we discussed

11.84

the uh the road map we added a road map

13.92

and a time frame

15.519

we have the ability to list and edit

18.48

road maps

19.52

so we're going to start working on the

20.72

time frame now one thing we're going to

22.8

adjust here we've got a

24.08

couple things we're going to do is uh a

26.8

time frame

27.76

is actually going to be tied to a

29.76

roadmap it's not going to tie

32.16

a task necessarily to

36.239

it's it's not going to be a direct link

37.92

there because we'll have a single time

39.36

frame

40.239

for example annual that would have

43.52

multiple tasks related to it and this is

47.28

uh a little bit to just help us in how

49.76

we're going to do this from a user

51.36

experience point of view

52.8

and that being that we're going to come

54.16

in and we're going to create a roadmap

56.32

as a user you'll create a roadmap

59.68

you can pull in time frames you'll

62

create a time frame

63.28

and then you're going to assign tasks to

66.4

the time frame

67.76

so here we're going to take

72.72

and actually what we're going to do to

74.32

make it really simple is we're now

76.32

going to say that every task is going to

78.88

need

79.6

a time frame and so we will come in

83.52

and do let's see we're just gonna call

86.479

him

89.6

uh because we don't have anything here

90.96

so we're gonna call we're gonna let me

92.56

uh

93.68

let's just pick like here copy this

97.04

because now a task will have a time

99.439

frame

104

and it's going to have a foreign key to

107.28

time frame

111.84

and the verbose name is going to be

115.68

time frame oops i'm going to do it this

118.88

way

121.2

so now we're going to be able to do that

123.52

and i do want to do

125.2

uh as we've seen before here we go so

128.239

you can have a null

129.2

and a blank and we're going to allow

131.68

that uh

132.8

technically we're probably not going to

134.16

have that so but

135.92

i guess we could we could have tests

137.28

that are not tied to time frames

140.4

so what we'll do is we'll come in we'll

141.84

create road maps we'll create a time

143.84

frame

144.72

and then we'll be able to uh once that's

148.08

done

148.4

we'll be able to tie tasks uh to a time

151.599

frame

152.239

and so we're gonna see uh lookups and

154.16

things like that through all of these so

155.68

we've changed our model

157.76

uh one of the things we're going to have

159.2

to do and let's start with

161.36

our forms so road map form

165.92

we're good but task form

170.16

is now going to have

173.599

the time frame whoops which again

176.8

i need to do it like that

182.319

and uh we need to create

185.76

for our model over here we need to

187.84

create

190

a form for our time frame

194.4

so we don't have one so let's do

197.84

i'll keep this so i can keep up with

199.2

what i need to deal with for my time

201.12

frame and i'm just going to replicate

204.319

this rather quickly

209.519

and this is not the roadmap form this is

211.28

going to be my time frame form

216.72

and the model is going to be models dot

220.799

time isn't going to kick it nope it's

222.72

not going to give me the auto complete

223.84

so it's going to be uh

226.319

models.time frame and the fields are

228.799

going to be

230

a little different here because we still

231.92

have a name

233.599

but we also have a roadmap

239.519

and a time frame

245.599

oh which is the time frame in itself

247.28

let's change that

251.2

to period instead

255.84

and he's going to be time frame actually

258

we'll just go ahead and change the whole

259.12

thing

260.72

so that's going to be period choices

262.16

oops i'm going to change that over

263.28

another one my mistake so we're going to

264.639

call him period instead of time frame

270.479

and we're going to start with something

272.16

moderately simple here let's say we

274.16

don't have a hidden input

277.759

and we're not using dates or anything

279.199

like that but we will keep the name

281.04

uh we're gonna have that so that's

283.759

standard size

285.04

so now let's uh so that should be our

287.28

time frame

288.08

form now let's go back over here and

291.28

we're gonna change that period so we're

292.639

gonna actually

293.28

do a little bit of tweaking here but

294.639

we're gonna see this when we

297.36

update when we do our migrations

300.639

we're going to see this stuff get

302

cleaned up for us we're going to rename

303.52

this to period

309.199

and let's see task is done there so we

312.8

got our task form

313.919

updated uh so let's see so

317.44

roadmap task oh

320.639

um oh we've got roadmap here so we have

323.84

those

326.08

we have let's group these a little bit

330

so we're going to group our task related

332.56

stuff

335.199

group our roadmap related stuff

339.919

and now we're basically going to have

341.28

those same things

345.759

i'll keep it somewhat similar and this

349.039

is going to be for a time frame

351.6

but we're just going to use tf as the

355.68

abbreviation for the url just to keep it

357.68

a little bit simpler

361.36

and we're going to be able to create a

363.039

time frame

366.56

uh list time frames

370.24

time frames

373.28

and edit time frame

378.4

so we've got those three create list and

380.4

edit and we're going to come over to

382.72

views wherever that went there we go

386.08

and let's see so if we can maybe steal

388.56

these create

392.84

lists

395.039

and well we'll start we'll push this to

397.52

the bottom

398.24

and we also need create tasks so where

401.68

is create there it is

406.8

and we're not going to bother with our

408

delete yet

411.039

so each of these was time frame

415.919

and let's just copy and paste that name

417.84

so we can get that done right so we're

419.759

going to take him there we're going to

421.28

edit it

422.24

we're going to list it and we're going

425.599

to create it

427.44

and i think i had an s at the end of

429.199

this if i look back over here where did

431.68

i put that

433.039

on my urls i had

436.72

list time frames okay so that's good so

439.039

that's multiple

440.72

and now uh again we're going to fairly

443.28

quickly be able to fly through these

444.88

things and make our changes so

446.56

that was actually it's the time frame

448.16

object let's make sure

450.08

yep i already got that upstairs upstairs

452.72

up at the top of the page

454.16

so let's jump back to the bottom and

457.52

let's see i don't really need to worry

459.039

about an owner because

461.28

they don't exist in this case this is no

464.24

longer the time frame for

465.52

task form it's the time frame form we'll

468.16

keep that the same

470

let's see we don't really have to worry

471.52

about delete i will leave it in there

473.919

even though we're not actually going to

477.039

uh well i guess we can we could take it

478.639

through here so uh let's see so we're

480.56

gonna do that that's our id

482.08

record deleted he's gonna go instead to

484.639

tfs

487.36

again this is a time frame form whoops

493.12

and we use this instance data form form

495.28

form save redirect to tfs

499.039

yen valid record good edit time frame

504.639

form title message and it's going to do

506.96

to

508.08

time frame edit because we're going to

510.8

and we'll have to make that so

512.159

task edit we're just duplicate that

516.8

and we're going to call him or her if

519.839

you want to be

520.64

picky about it time frame edit

523.839

and we're also going to need uh task

527.2

list is going to become

531.44

time frame list

537.2

so we had our two tasks we have our time

539.519

frame so we're getting ourselves

540.959

somewhat going here and they'll look

543.04

somewhat similar because we are

544.959

this makes it a little easier because

547.519

we're sort of staying the same

549.76

as far as some of our parameters that

551.68

are going in

552.88

uh here let's see so we do like list

557.839

we have titles and tasks we could keep

559.68

that but we're gonna we'll clean that up

561.2

a little bit

562.08

just for uh user's sake but if we wanted

566.16

we could call this items or something

569.44

like that

570.32

and then or i'm sorry this part the

572.48

variable would be items

573.92

we're just gonna pass different items in

575.6

and we could probably use actually the

577.04

same

578.08

form for the most part um especially for

580.56

the listing

581.2

especially because everybody's got a

582.399

name there's some ways we can do this

584

that we could make it

585.279

really easy to limit our code and not

588.24

have to reproduce stuff almost

590.32

almost at all so this could be all

593.839

time frames because we are getting all

597.68

of them

602.8

we're just going to call this tfs time

604.64

frames and this is going to be tfs

606.72

time frames because i don't feel like

607.92

typing as much

610

and um let's just call this frame

613.279

uh no because framework it won't like

614.72

that so we're going to call this we'll

616.079

just keep it

616.959

time frames and this is going to go to

620.48

time frame list

624.399

create a time frame we're going to clean

626.079

this up here

628.88

it's going to be a time frame form and

630.8

create new record create a time frame

637.12

time frame form

640.24

come in let's see invalid record blah

641.839

blah blah blah blah blah blah time frame

643.44

edit

645.76

and so we've cranked those out real

648.64

quick and so let's go look at our time

650.56

frame edit

652.64

uh let's see it's actually in pretty

655.519

good

656.16

shape uh there's nothing we have to do

658.399

specific there

661.279

so it actually could be

664.72

we could actually send it to task edit

666.959

so we could do like generic edit

668.8

send it there but we're not going to do

670.959

that right now

672.88

um let's see and then so oh timeframe

675.68

list

676.72

so now this one's where we're going to

678

deal with this a little bit because

680.64

uh so complete task doesn't really

683.279

matter for a task

687.36

and yeah let's get rid of that for now

689.839

uh and it wasn't

690.8

tasks it's time frames

696.64

and for uh we'll just call it tf

700.16

so time frame in time frames

705.519

and then there's gonna be a class um

710.72

let's call it time frame

714.399

uh this is gonna be a css style so we

716.32

had a task uh let's

718.24

fix that real quick so we had tasks

721.6

and this is going to be

723.18

[Music]

724.639

oh sorry control c control v

728

and then we're just gonna call it time

729.44

frame

731.12

for now we're going to leave it the same

733.12

as a task but we're going to come back

734.56

and make some changes to it at some

736.16

point so

737.279

let's go back to our time frame edit

740.959

did we oh shoot that was the wrong page

753.44

it's probably not going to like me let's

754.8

see if i can get back over here

758

let's see

800.8

three two one

803.839

so let's make sure we save this when we

806.56

do our edit

807.76

we can go to our list

810.959

and let's go back here so we have a time

812.48

frame it's going to be

814.24

instead we're going to give it an id of

816.399

tf underscore

818.48

it's going to be tfid the name is going

821.44

to be the

822.32

time frame name we don't need to have a

824.24

due date

825.839

actually most of this stuff i don't

826.88

think we're going to have let's get rid

829.199

of our break there we don't need a

830.48

status we don't need a time

832.88

we do want an edit

836.399

and we don't need a complete

840.639

and so it's gonna go to uh time frame

845.44

and it's gonna be time frame id no time

849.12

frames

854.839

available

857.44

and so that's going to give us our

860.48

uh listing let's see i think

864.32

we'll do a file save all so let's go

867.68

play around and see if we can do our

869.44

whoops

870.079

let's see uh well that's right that one

872.8

works i want to do my

875.68

make migrations because we made some

877.36

changes to the model

882

uh timeframe is not defined so i missed

883.92

something somewhere in models line 21.

886.16

okay

888.959

oh this may be a issue that we have

894.8

so line 21 time frame has not been

896.639

created yet

898.399

so uh

901.519

because this is gonna go top to bottom i

903.199

don't know if we've mentioned this

904.079

before

905.68

you can't add something that refers

908.959

to something that's defined later in the

911.36

file

912.56

so this time frame that we refer to has

915.839

to already be created

917.12

so if we do that let's see if that works

920.079

for us

922

time frame choice oops i didn't change

924.079

my

925.279

when i changed it i didn't get

926.399

everything's changed properly

928.48

period choice oh this needs to be

933.519

period choices

938.959

and i think that will do it

944.24

so now we make migrations uh let's see i

946.56

know field time frames testify for task

951.519

so let's take a look at that

958.32

time frame time frame got it

965.199

oh let's see what am i complaining about

966.959

here it's probably somewhere else so if

968.32

i go to

969.759

oh forms

973.36

line 28 so there's something wrong there

976

so let's go

976.639

to our forms 28 there's a task form

987.519

oh i bet

991.839

task form is time frame let's see what i

994.32

complain about

996

let's look again it said that

1001.04

let's see unknown field time frame

1003.12

specified for task so if we go look at

1005.279

task

1008.48

uh in our models where's our models

1010.079

there's our models

1012.639

time frame lowercase um that's the

1015.92

verbose name so the actual one is

1017.36

lowercase is how we're gonna

1018.88

list uh access it where did i go to my

1021.04

forms

1022.24

so here that's not capital t it's

1024.4

lowercase t

1025.76

time frame

1029.679

hopefully that got all the things right

1032

let's see

1036.4

so did you rename that to period yes

1038.88

because we did rename it

1042

and so now we can do migrate

1049.039

and so now we should be able to run it

1052.88

and if we go to our link over here and

1055.919

log in then we can see things like

1060

uh let's see i think roadmap we had so

1062.08

we could go in and we can edit a roadmap

1065.12

now what we don't have is a time frame

1068.48

so we're just going to call it uh tfs

1072.16

to get us that time frame list

1075.6

uh and so it's going to say cannot

1077.28

resolve due date oh i've got something

1078.64

left over here

1080.559

oh there we go i've got an order by so

1082.64

i've got to go fix that

1085.6

and so if i go to view i had

1088.88

an order by in list

1092.16

so it's order by name

1096.72

and that probably will fix it and there

1098.799

we go no time frames available

1100.559

so we covered a lot of ground

1103.679

i'm going to call it a a session right

1106.64

now

1107.2

and um we will come back around next

1109.679

time

1110.559

and we're going to get a little deeper

1111.679

into hooking our tasks and time frames

1113.84

and road maps together so

1116.4

as always uh thanks for listening we do

1118.799

have you'll see this tag

1120.16

day 30 on our github as far as the code

1123.679

that i'm gonna

1124.559

that we've looked at today and then as

1127.44

always go out there have stuff a great

1128.799

day

1129.12

and we will talk to you next time