Detailed Notes
Our focus today is on self-referencing models as we start to provide for timeframe parent-child relationships.
You can view source for today and all prior days by reviewing the tag Day 33 (32 and 33 were combined in that tag) at this GitHub address: https://github.com/robbroadhead/develpreneur-pythontutorial
Transcript Text
[Music] well hello and welcome back we are continuing our python django series tutorials and we are digging into building out our application today we're going to uh make it a little more like an application we've been essentially hacking our way through some of these things making some uh yeah making some sort of quick fixes and quick links and stuff like that and we're gonna start moving forward into you know cleaning it up a little bit so first thing we'll do is we're gonna start with the login page and so here you can see we come in and we've got a login that's sort of you know in the way there and so whoops let's go over here and let's go to our login which i believe was home page maybe oh no it's login here and this extends base i think we have everything we need instead of simply doing this login and then a form method uh let's go ahead and center it out a little bit so we're just going to do div class equals container so i think we looked at that before and this just gives us a sort of a general let's see in block whoops i want to put it before the end block and it's going to give us something so we can put it inside so if i just save this so it's going to clean it up just the slightest amount so i go here now it's over because remember we have is our container we have some gutters on both sides but now let's take that and we're going to take him and do uh let's see we'll do it within here so we're going to do and we're just going to do it it's going to be a full length so it's going to be a col we're gonna do an md and this is a bootstrap thing uh let's see table there we go and what this does basically you can within bootstrap you have uh essentially it divides the screen the page into 12 spots 12 columns essentially and those adjust based on whether or not you're shrinking your screen or not so right now we're going to say this is basically effectively a whole row which we could actually let's just keep it a row for now and i think we can do an align equals center and clean it up just a little bit so if we go here oh that's not what i wanted to do so let's do it this way we're going to cheat um this is another way to center stuff so we're going to come in and we're going to do let's have a row we're gonna do class equals remember you i just mentioned that you can split uh bootstrap allows you to split stuff up in twelfths essentially so we're gonna say that that's probably and about a third so what we can do is we're going to do a responsive split in bsp so we're going to give it a space because it wants a space within that div and then we're going to do three such divs so let's see so we do that one that one that one and this one make sure i've got that balanced so now what we're doing is we're saying i want some i want a bigger column basically to left a bigger column to the right and then put the other one in the middle and it's still not picking it up right i wonder why it's not oh i bet it's not let's go look back at bass because it may not be picking up bootstrap which could be part of my problem uh it should be picking that up so let's go take a look at that real quick and we're gonna see here he's an md4 and if we look at the style here let's see so md4 is picked up by grid scss oh you know what it is is because i'm not forcing that thing to be a row let's just go back here and wrap that thing in a row and see what happens because otherwise it's just going to sort of split spread stuff out as it deems necessary which essentially will end up stacking them so if we looked here so yeah here if you look here the first md4 is actually it's unknown it's its own row the next one is a row the next one is row but now oh and i need to change my login now because we put it within a row if we go into the container and look within that row now we see our fours beside each other and so let's just change the please log in i think i can do it on line equals center let's see if that works if is it that simple yes okay so i can do please log in i'm going to make it an h2 and i'm just going to slap a couple of rows above that let's do three of them now i could make this something where this header is through css let's do it this way i could make it so that that is spaced out you know specifically i could do a login form or something like that but i'm keeping it source simple here uh whoop i don't want to save it i want to do that and so now we log in now one of the things once we log in we go to this home page which is not terribly interesting what i want to do is i'm going to change it i'm going to go right to my to-do list so that means within my views actually i can probably see it if i go to my login uh let's see oh well let's go look at that let's go look here where's login login log in let's see so i may have sent it and let's go take a look at that i think well let's go look at our url so when i come into homepage homepage will redirect to login which redirects to probably default let's see so if we go here it's going to do a login it's going to submit now one of the things we saw before is that i think we've talked about the ability to forward like if we look at our i think it's in base i go page home what was our other one internal uh that also does so let's flip back over here so what we want to look at where was the actual homepage homepage here uh this is the homepage so let's go see what we're displaying a whole page okay so we must be doing that here oh here we are oh that's home too i don't think we need home too nor do we need about oh here we go i'm sorry so uh profile we've got our template name is homepage.html and instead what we want to do is because i think we can do it this way is we're going to go to our active tasks which is our to-do as we see up here so now if we do active tasks okay so that should work so now if we go in here and we log out and we log in now it brings us to active tasks and so home uh is bringing us to login so let's take a look at that let's see so we want to go to that's our internal and so home here takes itself slash which takes us to home page oh and what we want to do here we're just doing a redirect instead we want to say if we are logged in which i think we've used that before so i may not so we can do it here and what we're going to do is we're going to say if request got user so if we're logged in then we're going to redirect to the to do otherwise and we'll just let it fall through otherwise we're gonna redirect to the login now what this does is this basically says hey if i'm logged in then i can go one place and if i'm not i can go somewhere else and this is something we can use actually and probably will start hooking up in several places oh and actually it's not as you i'm going to do is authenticated and dk did and actually what we can do is let's just we're going to use this in a couple places so if not request.user is authenticated so if they're not logged in and then in that case we're going to redirect them to the login and otherwise they go to the to do and so actually we can do that here to a couple of things so like completing a task let's make sure that they're logged in uh show page we have to worry about that uh user registration form no creating a task let's make sure that they are and these are because we're using the request.user we want to make sure that they're validated uh let's see don't worry about test mass update definitely uh edit a task we definitely need to be logged in listing our tasks listing our road maps creating a road map and so this is also going to help us in several cases where we were setting the owner to a request user if there is no request user which means they're not authenticated then we're going to run into some issues let's see active tasks edit the time frame so we're going to start doing this as part of our our views is we'll just make sure that we are authenticated so now i've gone through we've done that if i do a login and now if i do a home it's going to come here if i log out and i do a home oh actually i can do it from here in this case it's going to bring me back to login so now it's not going to keep kicking me back to log in and let's see so i can i'll leave well because i'm going to come to home i'm going to get rid of to do out of my menu items so i can get rid of that and that's in internal so i don't need to worry about that anymore and now let's continue with our application so now we're going to come in here we see this well if you remember we were working on our roadmaps so our roadmaps we've got one and we could create a new one if we want but let's keep with this one so let's sort of flesh out this road map so this road map we've come in we've got a due date we have some time frames so we've got overall annual goals and then we've got um first quarter now what we wanted to do is we wanted to be able to set a a time frame to have uh another time frame as a parent and so let's go jump into that um actually let's not this time uh so let's go in and uh we're going to do because we're going to have a couple of things we're going to pick up next time because we are short this time around so then one of the things we want to do and we i think we already did it is for our overall annual goals we added some tasks now we can do that also for our quarterly goals so i can create for this period let's say i'm going to create uh application version one so we'll have a couple of pieces of data to work with next time around so create application version one due date uh march the end of march we'll just pick a date towards the end of that i'm not going to attach a file it's not completed it is new uh time frame and this is for the first quarter now one of the things we see here that we're also going to tackle is okay so i save that now there's two things i came to here from first quarter so what i'm going to want to do is use that as essentially as a default and i want a way to go back as opposed to doing this you know back which now i got to go back through this and then i go back through it what i want to do is i'm going to with this i'm now going to have a way to essentially go back to the period that i'm working with so that's what we're going to tackle next time i've gone a little long this time playing around with stuff but next time what we're going to focus on is having some sort of a structure within our tasks and our roadmap uh goals so that we can you know time periods so that we can start flushing this thing out a little bit that'll do it this time around so go out there have yourself a great day and we will talk to you next time you
Transcript Segments
[Music]
well hello and welcome back
we are continuing our python django
series tutorials
and we are digging into building out our
application
today we're going to uh make it a little
more like an application we've been
essentially hacking our way through some
of these things making some
uh yeah making some sort of quick fixes
and quick links and stuff like that
and we're gonna start moving forward
into you know cleaning it up a little
bit
so first thing we'll do is we're gonna
start with the login page
and so here you can see we come in and
we've got a login that's sort of you
know in the way there and so whoops
let's go over here
and let's go to our login which i
believe
was home page maybe oh no it's login
here
and this extends base i think we have
everything we need
instead of simply doing this
login and then a form method uh let's go
ahead and center it out a little bit so
we're just going to do
div class equals container so i think we
looked at that before
and this just gives us a
sort of a general let's see in block
whoops i want to put it before the end
block
and it's going to give us something so
we can put it inside so if i just save
this
so it's going to clean it up just the
slightest amount
so i go here now it's over because
remember we have is our container we
have some
gutters on both sides but now let's take
that
and we're going to take him and do
uh let's see we'll do it within here so
we're going to do
and we're just going to do it it's going
to be a full length so it's going to be
a
col we're gonna do an md and this is a
bootstrap
thing uh let's see table there we go
and what this does basically you can
within bootstrap
you have uh essentially it divides the
screen the page into
12 spots 12 columns essentially
and those adjust based on whether or not
you're shrinking your screen or not
so right now we're going to say this is
basically effectively a whole row
which we could actually let's just keep
it a row for now
and i think we can do an align equals
center
and clean it up just a little bit so if
we go here
oh that's not what i wanted to do
so let's do it this way we're going to
cheat um this is another way to center
stuff so we're going to come in
and we're going to do let's have a row
we're gonna do class equals remember you
i just mentioned that you can
split uh bootstrap allows you to split
stuff up
in twelfths essentially so we're gonna
say
that that's probably and about a third
so what we can do is
we're going to do a responsive
split in bsp so we're going to give it a
space because it
wants a space within that div
and then we're going to do three such
divs so let's see so we do that one that
one
that one and this one
make sure i've got that balanced so now
what we're doing is we're saying i want
some
i want a bigger column basically to left
a bigger column to the right and then
put the other one in the middle
and it's still not picking it up right i
wonder why it's not oh
i bet it's not let's go look back at
bass because it may not be picking up
bootstrap which could be part of my
problem
uh it should be picking that up
so let's go take a look at that real
quick
and we're gonna see here he's an md4
and if we look at the style here
let's see so md4 is picked up by
grid scss
oh you know what it is is because i'm
not forcing that thing to be a
row let's just go back here
and wrap that thing in a row and see
what happens
because otherwise it's just going to
sort of split spread stuff out as
it deems necessary
which essentially will end up stacking
them so if we looked here
so yeah here if you look here the first
md4 is actually it's unknown
it's its own row the next one is a row
the next one is row
but now oh and i need to change my login
now because we put it within a row if we
go into the container and look
within that row now we see our fours
beside each other
and so let's just change the please log
in i think i can do it on line equals
center
let's see if that works if is it that
simple
yes okay so i can do please log in i'm
going to make it an
h2 and i'm just going to slap
a couple of rows
above that let's do three of them
now i could make this something where
this header is through css
let's do it this way i could make it so
that that is spaced out you know
specifically i could do
a login form or something like that but
i'm keeping it source simple here
uh whoop i don't want to save it i want
to do that
and so now we log in now one of the
things once we log in
we go to this home page which is not
terribly interesting what i want to do
is i'm going to change it i'm going to
go right to my to-do list
so that means within my views
actually i can probably see it
if i go to my login uh
let's see oh well let's go look at that
let's go look here
where's login login log in
let's see so i may have sent it
and let's go take a look at that i think
well let's go look at our url so when i
come into homepage
homepage will redirect to login
which redirects
to probably default
let's see so if we go
here it's going to do a login it's going
to submit
now one of the things we saw before is
that i think we've talked about the
ability to
forward like if we look at our i think
it's in base
i go page home what was our other one
internal uh that also does
so let's flip back over here
so what we want to look at where was the
actual homepage homepage here
uh this is the homepage so let's go see
what we're displaying
a whole page
okay so we must be doing that here oh
here we are
oh that's home too i don't think we need
home too nor do we need about
oh here we go i'm sorry so uh profile
we've got our
template name is homepage.html
and instead what we want to do
is because i think we can do it this way
is we're going to go to our active tasks
which is our to-do
as we see up here so now if we do active
tasks
okay so that should work so now if we go
in here
and we log out and we log in now it
brings us to active tasks
and so home uh is bringing us to login
so let's take a look at that
let's see so we want to go to that's our
internal
and so home here takes itself slash
which takes us to home page oh and what
we want to do here we're just doing a
redirect
instead we want to say if we are logged
in
which i think we've used that before
so i may not so we can do it here and
what we're going to do is we're going to
say if request
got user so if we're logged in
then we're going to redirect to
the to do
otherwise and we'll just let it fall
through otherwise we're gonna redirect
to the
login now what this does is this
basically says hey if i'm logged in
then i can go one place and if i'm not i
can go somewhere else
and this is something we can use
actually and probably will start
hooking up in several places
oh and actually it's not as you i'm
going to do is
authenticated and dk
did and actually what we can do
is let's just we're going to use this in
a couple places so if not
request.user is authenticated so if
they're not logged in and then in that
case
we're going to redirect them to the
login
and otherwise they go to the to do
and so actually we can do that here to a
couple of things so like completing a
task
let's make sure that they're logged in
uh show page we have to worry about that
uh user registration form no creating a
task let's make sure that they are and
these are because we're using the
request.user
we want to make sure that they're
validated
uh let's see don't worry about test mass
update definitely
uh edit a task we definitely need to be
logged in
listing our tasks listing our road maps
creating a road map
and so this is also going to help us in
several cases where we were
setting the owner to a request user if
there is no request user which means
they're not authenticated
then we're going to run into some issues
let's see active tasks
edit the time frame so we're going to
start doing this as part
of our our views
is we'll just make sure that we are
authenticated so now
i've gone through we've done that if i
do a login
and now if i do a home it's going to
come here if i log out
and i do a home oh actually i can do it
from here
in this case it's going to bring me back
to login so now it's not going to keep
kicking me back to log in
and let's see so i can i'll leave
well because i'm going to come to home
i'm going to get rid of to do
out of my menu items
so i can get rid of that and that's in
internal
so i don't need to worry about that
anymore
and now let's continue with our
application so now
we're going to come in here we see this
well if you remember we were working on
our roadmaps
so our roadmaps we've got one
and we could create a new one if we want
but let's keep with this one so let's
sort of
flesh out this road map so this road map
we've come in we've got a due date
we have some time frames
so we've got overall annual goals and
then we've got
um first quarter now what we wanted to
do is we wanted to be able to set a
a time frame to have uh another time
frame
as a parent and so let's go jump into
that
um actually let's not this time
uh so let's go in and uh we're going to
do because we're going to have a couple
of things we're going to pick up next
time
because we are short this time around so
then one of the things we want to do
and we i think we already did it is for
our overall annual goals we added
some tasks now we can do that
also for our quarterly goals
so i can create for this period let's
say
i'm going to create uh application
version one
so we'll have a couple of pieces of data
to work with next time around so create
application version one
due date uh march the end of march
we'll just pick a date towards the end
of that i'm not going to attach a file
it's not completed it is new
uh time frame and this is for the first
quarter
now one of the things we see here that
we're also going to tackle
is okay so i save that now there's two
things i came to here from first quarter
so what i'm going to want to do is use
that as essentially as a default
and i want a way to go back as opposed
to doing this you know back
which now i got to go back through this
and then i go back through it
what i want to do is i'm going to with
this
i'm now going to have a way to
essentially go back to
the period that i'm working with so
that's what we're going to tackle next
time
i've gone a little long this time
playing around with stuff but next time
what we're going to focus on
is having some sort of a structure
within our
tasks and our roadmap uh goals
so that we can you know time periods so
that we can start flushing this thing
out a little bit
that'll do it this time around so go out
there have yourself a great day
and we will talk to you next time
you