📺 Develpreneur YouTube Episode

Video + transcript

Learn Python and Django Day 29

2021-02-04 •Youtube

Detailed Notes

This session continues building out our goals applications. We are working on doing edits and deletes of our roadmap data.

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

Transcript Text
[Music]
well hello
and welcome back we're continuing our
python django
application build out and if you
remember last time we were working on
our roadmaps and we really had just sort
of gotten into
the basics we focused on the model this
time around we're going to actually
add some more pieces to this uh one of
the things i want to do
as part of this is notice how we're sort
of bumped up here
so what we're going to do is we're going
to go back to our
list and i'm just going to do something
very simple
i'm going to put all of this into
a div that's going to be a container and
this is a
bootstrap thing
and so i'm gonna do that and it's just
gonna allow me to make stuff
uh look a little bit better and so if i
just do that
and go here i'm gonna see that now and
we're going to play around with our
containers a little bit but now it sort
of offsets stuff a little bit so it
doesn't look
so cramped within there
we are also going to
let's start with being able to create
one so
uh before and this is in the ability to
continue to reuse stuff we had task edit
so we're gonna duplicate that
and now it's going to be road map edit
and we're going to come into our uh well
let's go to our url so let's start from
our urls
so before we had uh where'd we put it
we had tasks oh here we go so we had
edit task
i'm gonna take that same thing
and this one's gonna be roadmap
now this is where a slight detour here
this is where we could potentially find
usage in
actually importing other files of urls
we did it here with we've done it with
admin
and some things like that we could also
see where we may want to do
for example since we have crud kind of
stuff
is that maybe everything that came off
of road map
you know let's say it could be we could
do road map edit
and road map add road map
delete road map
list and then have sort of a series
of of urls based off of those
in which case we could push all that
into a single file
and include it much like we did with
accounts
because here we had this path accounts
and we include it's just going to attack
everything in django contrib auth urls
to accounts so we could make it actually
simpler here
and instead like task and how we're
doing tasks and tasks and all that kind
of stuff
we could make a set of url patterns
that are basically driven by the the
core object that they work with
and um make it a little cleaner and
easier and
particularly you're building an api or
something like that it may seem much
easier to
much more user-friendly
we're not going to do that right now i
just wanted to mention that so we're
going to come in and instead edit tasks
it's going to be edit road map
and with an id so let's go find
edit task there it is
and this is now going to be
let's move it down here by list roadmaps
that's going to be edit roadmap it's
still going to be
take that id the data now is going to be
instead of task it's going to be roadmap
the owner is going to be the same and
now we're going to use the roadmap form
let's see keep the message there
post we're going to allow it to delete
just because
except for now it's going to be roadmaps
i think that's what we called it
yep roadmaps
uh it's going to be a road map instead
of a task
now this is a note that is a danger if
we
going through and copy and pasting our
way through this stuff is that if we
miss something
uh it could become rather bad
for example like if i didn't update the
roadmap to task it would still work
assuming that the roadmap id that we
send for delete
actually exists as a task it would
actually delete that task so we have to
watch this
i'm going to have to go through it sort
of line by line
but notice how quickly we can get
through this stuff so we've got a
roadmap form
if it's valid it's saved we're going to
redirect roadmaps
it's either a valid record the title is
going to be edit roadmap
title message and then it's going to be
roadmap edit
and then let's save all save that
and if we go to roadmap edit
since we use the form it's actually
going to be pretty straightforward so
we've got our
save we've got our delete we really have
uh let's go ahead and put this in a
container as well
which we probably actually let's be
really
slick about this so our content let's
make it always a container so let me go
back to our roadmap list
it's again using that
blocks using our blocks in a very useful
way so if we go back to
uh normally this is enter let's do
everything internal
we're going to wrap it in a container
and so now we're going to see here so it
should still look here so there's my
roadmaps
about is an internal create a task so
now we've got all of these guys
i broke to do somewhere
um but that's okay we'll come back to
these a little bit
so notice now we've got a container for
everything okay
uh oh let's go back to
road maps now uh one of the things we're
gonna do
is we're gonna clean up our our
navigation a little bit here
so first let's do just a task list
we're going to take that and this is
going to be roadmap
so we'll get that and we're not going to
have a create task directly anymore
we're going to keep tasks to do
actually we're going to probably get rid
of tasks but we'll leave that for now
and let's move about to the end
towards where log out is and
that'll work for now so now we can get
to our road maps
but because we don't have a way to
create a road map
we're going to go here and we're going
to want to have a button
so we have edit
and let's see that was in our
items but then above there we're going
to have one here
that's just going to be
create road map
and i believe we just want to send it to
zero
because i think that was how we set
create so let's go take a look at how we
did
uh where did we do create create create
create
so i think for yeah i think we just sent
it let's go back and look at our
navigation real quick
when we did oh create tasks just went to
task
okay
so if we go to task task task task it
just did create tasks so let's just do
that we'll keep that
so if we don't do it so road map without
an id
is going to be create roadmap
uh let's go back to our roadmap list
so it's just going to go to roadmap
and so now we want to take so
we got our url set up oh now let's get
our view
so let's go look for
create there we go create tasks so now
we're going to do the same thing we did
before
and this is going to be create roadmap
we'll put it down here sort of group it
with the roadmap stuff
data is going to be a roadmap
roadmap form
create a new record create roadmap
post is going to come in and it's still
going to be now it's going to be a
roadmap form
foul valid valid invalid record bam bam
bam and it's going to do road map edit
which we already created i believe
somewhere
yeah with edit roadmap
so now uh let's see got roadmap
edit so actually now we should be able
to take a look
we did a lot of changes here so now we
can see our road map list we've come to
home
uh log in let's do road maps
so now there's no road maps created oh
notice that that's all bumped together
so let's go back real quickly
and in our roadmap list we're going to
just do
a let's just do a line break
actually let's do two
we may clean this up and do some nice
stuff better later but for now
do that so you could create a roadmap
and we don't have any credits now let's
create one
create a roadmap create a new record um
and we'll leave that for now so this is
going to be
uh annual goals
2021 yeah and notice we had that
help text there due date
we will make it a due date of december
31st
2021. so at the end of the year when i
get that thing done we're going to save
it
see if it works it does uh we did not
on a save go back
so let's go take a look at that
if we go to our views
let's see that was edit
and so here what we really want to do
is we want to do let's see if it's a
post
under redirect
and on creating
a roadmap here if it's a post
instead of going through all of this
stuff we're actually going to go through
and say we did everything we needed to
we're going to redirect two
roadmaps and have it go back to
our item we don't need to worry about
that right now so if we go to our list
we're going to see that we now have our
annual goals
and if we edit it uh we do not
have our edits set up right so let's go
take a look at that
roadmap
urls oh i don't think i oh i did roadmap
edit edit roadmap
maybe i did not get my id right let's
take a look here well let's go back and
look here
oh it didn't add an id so if we look
here
it's not roadmap id it is item id
so let's go back refresh our page
now it should go and boom we're able to
edit it
and we'll add a little text here save
the record
oh i got a delete in there somewhere
what we want to do is
if let's do this delete
in request.post
and we're going to do that for our
up here for the other
delete that we used because we want to
fix that
it's a good and the bad of copy and
paste so if we do all of those
and now we come back let's make sure
we're running
we are and now if we resend it let's see
if we get anything so we do
uh and we can see that we updated our
name here
and so we were able to now build out a
road map
uh the next thing we're going to do is
we're going to need to actually tie
a task to a road map so we'll actually
do a
a master detail relationship and we will
cover that
in the next episode because i want to
keep this one short i don't want to get
too complex in it so we're just going to
keep
chugging along and adding values uh
value to our little application so
i hope this helped you out as always you
can check out the link in the show notes
this will be tag day 29 if you want to
see the latest code
as always go out there have yourself a
great day and we will talk to you
next time
Transcript Segments
0.63

[Music]

26.24

well hello

26.96

and welcome back we're continuing our

29.359

python django

30.48

application build out and if you

32.8

remember last time we were working on

34.8

our roadmaps and we really had just sort

38.079

of gotten into

39.12

the basics we focused on the model this

41.6

time around we're going to actually

42.719

add some more pieces to this uh one of

45.12

the things i want to do

46.48

as part of this is notice how we're sort

49.52

of bumped up here

50.96

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

52.32

to go back to our

55.199

list and i'm just going to do something

58.239

very simple

59.84

i'm going to put all of this into

63.92

a div that's going to be a container and

66.479

this is a

67.6

bootstrap thing

72.56

and so i'm gonna do that and it's just

75.6

gonna allow me to make stuff

78.24

uh look a little bit better and so if i

80.64

just do that

82.4

and go here i'm gonna see that now and

85.439

we're going to play around with our

86.32

containers a little bit but now it sort

87.439

of offsets stuff a little bit so it

88.72

doesn't look

89.439

so cramped within there

92.64

we are also going to

96.72

let's start with being able to create

99.36

one so

100.96

uh before and this is in the ability to

103.52

continue to reuse stuff we had task edit

106.56

so we're gonna duplicate that

110.479

and now it's going to be road map edit

119.92

and we're going to come into our uh well

122.159

let's go to our url so let's start from

123.6

our urls

124.64

so before we had uh where'd we put it

129.599

we had tasks oh here we go so we had

132.319

edit task

133.36

i'm gonna take that same thing

136.879

and this one's gonna be roadmap

143.36

now this is where a slight detour here

146.64

this is where we could potentially find

148.72

usage in

150.319

actually importing other files of urls

155.28

we did it here with we've done it with

157.68

admin

158.319

and some things like that we could also

161.519

see where we may want to do

164.16

for example since we have crud kind of

166.64

stuff

167.92

is that maybe everything that came off

170.16

of road map

171.519

you know let's say it could be we could

173.04

do road map edit

174.64

and road map add road map

177.92

delete road map

181.519

list and then have sort of a series

184.56

of of urls based off of those

189.36

in which case we could push all that

192.319

into a single file

194.08

and include it much like we did with

195.84

accounts

197.44

because here we had this path accounts

200.319

and we include it's just going to attack

202.159

everything in django contrib auth urls

205.84

to accounts so we could make it actually

208.72

simpler here

210.239

and instead like task and how we're

212.799

doing tasks and tasks and all that kind

214.56

of stuff

215.599

we could make a set of url patterns

218.959

that are basically driven by the the

221.599

core object that they work with

224.48

and um make it a little cleaner and

227.28

easier and

228.4

particularly you're building an api or

229.84

something like that it may seem much

231.44

easier to

232.56

much more user-friendly

236.64

we're not going to do that right now i

237.68

just wanted to mention that so we're

238.799

going to come in and instead edit tasks

240.239

it's going to be edit road map

241.84

and with an id so let's go find

245.04

edit task there it is

250.48

and this is now going to be

254.159

let's move it down here by list roadmaps

258.639

that's going to be edit roadmap it's

260.32

still going to be

262.16

take that id the data now is going to be

265.919

instead of task it's going to be roadmap

269.12

the owner is going to be the same and

270.72

now we're going to use the roadmap form

276.24

let's see keep the message there

279.68

post we're going to allow it to delete

281.52

just because

284.639

except for now it's going to be roadmaps

287.28

i think that's what we called it

292

yep roadmaps

295.44

uh it's going to be a road map instead

297.12

of a task

299.12

now this is a note that is a danger if

302.32

we

302.88

going through and copy and pasting our

304.32

way through this stuff is that if we

306.16

miss something

307.36

uh it could become rather bad

310.72

for example like if i didn't update the

312.72

roadmap to task it would still work

314.96

assuming that the roadmap id that we

318.88

send for delete

320

actually exists as a task it would

322.32

actually delete that task so we have to

323.84

watch this

325.039

i'm going to have to go through it sort

326.16

of line by line

329.12

but notice how quickly we can get

330.479

through this stuff so we've got a

331.44

roadmap form

333.12

if it's valid it's saved we're going to

334.479

redirect roadmaps

339.039

it's either a valid record the title is

340.88

going to be edit roadmap

344.96

title message and then it's going to be

346.24

roadmap edit

352

and then let's save all save that

355.28

and if we go to roadmap edit

360.639

since we use the form it's actually

362.88

going to be pretty straightforward so

364.479

we've got our

365.84

save we've got our delete we really have

369.759

uh let's go ahead and put this in a

372.479

container as well

377.84

which we probably actually let's be

381.12

really

381.6

slick about this so our content let's

384.319

make it always a container so let me go

386.16

back to our roadmap list

389.68

it's again using that

393.44

blocks using our blocks in a very useful

396.319

way so if we go back to

397.84

uh normally this is enter let's do

399.36

everything internal

402.319

we're going to wrap it in a container

409.68

and so now we're going to see here so it

412.72

should still look here so there's my

414

roadmaps

415.199

about is an internal create a task so

417.84

now we've got all of these guys

420.56

i broke to do somewhere

423.919

um but that's okay we'll come back to

427.12

these a little bit

427.759

so notice now we've got a container for

429.44

everything okay

431.68

uh oh let's go back to

437.12

road maps now uh one of the things we're

440

gonna do

441.28

is we're gonna clean up our our

444.319

navigation a little bit here

448.08

so first let's do just a task list

451.84

we're going to take that and this is

454.639

going to be roadmap

461.68

so we'll get that and we're not going to

463.919

have a create task directly anymore

467.919

we're going to keep tasks to do

472.479

actually we're going to probably get rid

473.44

of tasks but we'll leave that for now

477.599

and let's move about to the end

480.639

towards where log out is and

485.039

that'll work for now so now we can get

487.12

to our road maps

488.4

but because we don't have a way to

490

create a road map

492.479

we're going to go here and we're going

493.919

to want to have a button

498.56

so we have edit

502.56

and let's see that was in our

506

items but then above there we're going

508.479

to have one here

510.16

that's just going to be

513.68

create road map

518.32

and i believe we just want to send it to

521.2

zero

521.76

because i think that was how we set

524.64

create so let's go take a look at how we

526.16

did

527.279

uh where did we do create create create

529.44

create

533.04

so i think for yeah i think we just sent

535.92

it let's go back and look at our

537.04

navigation real quick

541.68

when we did oh create tasks just went to

545.92

task

546.839

okay

551.279

so if we go to task task task task it

554.72

just did create tasks so let's just do

556.32

that we'll keep that

557.92

so if we don't do it so road map without

561.76

an id

564.48

is going to be create roadmap

570.399

uh let's go back to our roadmap list

573.519

so it's just going to go to roadmap

580.24

and so now we want to take so

583.92

we got our url set up oh now let's get

587.44

our view

588.56

so let's go look for

593.6

create there we go create tasks so now

595.36

we're going to do the same thing we did

596.64

before

599.6

and this is going to be create roadmap

602.72

we'll put it down here sort of group it

604.079

with the roadmap stuff

611.6

data is going to be a roadmap

615.36

roadmap form

620.32

create a new record create roadmap

625.6

post is going to come in and it's still

627.519

going to be now it's going to be a

628.399

roadmap form

632.079

foul valid valid invalid record bam bam

634.56

bam and it's going to do road map edit

640.959

which we already created i believe

643.839

somewhere

645.04

yeah with edit roadmap

648.959

so now uh let's see got roadmap

652.8

edit so actually now we should be able

655.36

to take a look

656.32

we did a lot of changes here so now we

658.959

can see our road map list we've come to

660.48

home

661.44

uh log in let's do road maps

665.44

so now there's no road maps created oh

667.279

notice that that's all bumped together

668.64

so let's go back real quickly

670.64

and in our roadmap list we're going to

673.92

just do

674.72

a let's just do a line break

678.48

actually let's do two

682.079

we may clean this up and do some nice

683.6

stuff better later but for now

686.64

do that so you could create a roadmap

688.48

and we don't have any credits now let's

690.079

create one

691.68

create a roadmap create a new record um

694.32

and we'll leave that for now so this is

695.92

going to be

697.519

uh annual goals

702.24

2021 yeah and notice we had that

706.079

help text there due date

709.44

we will make it a due date of december

712.399

31st

715.76

2021. so at the end of the year when i

718.32

get that thing done we're going to save

719.6

it

720.48

see if it works it does uh we did not

723.839

on a save go back

727.2

so let's go take a look at that

730.32

if we go to our views

734.56

let's see that was edit

741.839

and so here what we really want to do

745.68

is we want to do let's see if it's a

747.839

post

748.88

under redirect

755.36

and on creating

759.279

a roadmap here if it's a post

762.88

instead of going through all of this

764.639

stuff we're actually going to go through

767.6

and say we did everything we needed to

769.2

we're going to redirect two

771.36

roadmaps and have it go back to

775.04

our item we don't need to worry about

778.399

that right now so if we go to our list

780.24

we're going to see that we now have our

782.72

annual goals

784.399

and if we edit it uh we do not

787.6

have our edits set up right so let's go

790.88

take a look at that

795.36

roadmap

798.48

urls oh i don't think i oh i did roadmap

801.519

edit edit roadmap

804.8

maybe i did not get my id right let's

806.56

take a look here well let's go back and

808.48

look here

811.6

oh it didn't add an id so if we look

814.959

here

815.76

it's not roadmap id it is item id

821.519

so let's go back refresh our page

825.519

now it should go and boom we're able to

827.76

edit it

830.8

and we'll add a little text here save

832.88

the record

838.399

oh i got a delete in there somewhere

841.36

what we want to do is

842.399

if let's do this delete

845.6

in request.post

850.88

and we're going to do that for our

855.44

up here for the other

858.56

delete that we used because we want to

860.24

fix that

864.72

it's a good and the bad of copy and

866.399

paste so if we do all of those

868.16

and now we come back let's make sure

870.079

we're running

871.44

we are and now if we resend it let's see

875.92

if we get anything so we do

877.76

uh and we can see that we updated our

880.56

name here

882.399

and so we were able to now build out a

885.12

road map

886

uh the next thing we're going to do is

888.399

we're going to need to actually tie

890.16

a task to a road map so we'll actually

892.72

do a

893.6

a master detail relationship and we will

896

cover that

897.199

in the next episode because i want to

899.6

keep this one short i don't want to get

900.88

too complex in it so we're just going to

902.48

keep

903.12

chugging along and adding values uh

906.32

value to our little application so

909.839

i hope this helped you out as always you

912.24

can check out the link in the show notes

915.279

this will be tag day 29 if you want to

917.92

see the latest code

919.68

as always go out there have yourself a

921.279

great day and we will talk to you

924.079

next time