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
[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