So awesome that we're able to show completed to DOS.
But let's go ahead and look at what other things we'd like to be able to do.
So I'm going to move back to my project, to the Urals, that pie for the whole project.
And I'm going to say, OK, I would like to be able to see the current to DOS.
And I also would like the ability to be able to create or generate one.
So let's use one of those, you know, list creates where we can both list out all the to DOS.
In our case, we're going to list out the current to DOS and then also allow someone to create a new
to do object.
So with that, let's go ahead and move over to our you URLs dot pi for the API and add this New York
URL that we're looking for.
So in this case, we're just going to call it to do so.
Going to copy what we have here.
I'm going to pace this and I'm going to say just simply to DOS, and we need to have a new class that
we're looking for here.
So let's go ahead and move over to the used up pie here inside of our API.
And we want to do a new class again.
I think this should be listing out things and allow people to also create.
So let's go ahead and copy the class that we have here.
We're gonna be reusing a lot of this, but paste this down below and I'm going to call this the to do
create list.
And instead of just the list API, we're gonna call this list, create API.
Let's let's have that be consistent.
Let's call this to do list create here.
OK.
So that's looking all good there.
We're still using to do serializer.
We want to make sure that someone is authenticated.
In this case, we want to make sure that the instead of the date completed is no.
We want this to be true to say, you know, these are things that have not been completed yet.
And we don't need to have the ordered by date completed.
Instead, let's go ahead and get from our to do here.
If someone were to get all of the to dos the current tattoos, I think it by default is naturally list
them out from when they're created.
So we don't need to do that.
But it's really just the true there.
So let's go ahead and move back and we can cut what we have there.
Great.
And really, the only thing that we need to do is add a little bit of special code when someone wants
to create a to do object.
And that's that we have to, you know, specify what user it is that this is going to be assigned to.
So let's go ahead and do a def perform, underscore, create.
OK.
And let's go ahead and pass self into there.
And like I said, the big thing that we want to do here is we want to take our serializer.
And I forget that's also something passed inside here.
So we have self and serializer.
OK, so now we're going to take our serializer dot save and inside of this save.
We want to make sure that we say user is equal to the self dot request dot user.
OK.
So really, that's all it takes to implement listing out current to DOS and also creating one.
This is why I love the jingle risk framework.
So I'm gonna save this fused up high.
I'm also going to save this you URL's file here.
Let's go back to the Web site.
So let's go to API slash to DOS, OK.
Once we're here.
Oh.
I think we have not switched that boolean because that let's go back to the views here.
The date completed is not true.
Yeah, that should be different there.
This is what it is.
We created this name of this class.
Forgot to put it into your LS here, so let's go ahead and paste that in.
Save this should be looking a lot better this time.
Let's hit enter and look at that.
We have listed out the one current to do that.
We have add an API to my site and you know, maybe the next thing we want to do is try adding it to
do.
And I think in the site, the thing that we should be adding next is the ability to, you know, you
know, update, delete those sorts of things.
So I'm going to say add update and delete here.
OK, so Memmo.
Hopefully.
Not too hard.
And this is a pretty important part of our Web site.
We're going to check that box.
I'm going to hit post and this is so cool.
It says this was successful.
And if I go back and I just want to see all the to dos here.
So let's go ahead and go back to just two dos.
Look at this.
They're listed out here.
There's add an API to my site, which we already had.
And then also this new add update and delete.
And again, what I just love about this is if I go to my current project and look at my current things,
both of those things are there.
Like the API is a living version of this Web site.
So exciting.
Well, we're on such a roll here.
Let's just go ahead and keep moving and add this functionality that we made a to do for.
Let's make it so that a user can update and delete a to do object.
So let's go ahead and move back to our project into the Urals dot pie for our API.
And let's add a new one here.
And this is going to be for someone, again, to view a current to do or update it, delete it, whatever
it is that they'd like to do.
So let's go ahead and copy and paste what we have from one of our existing ads.
But say this is going to be to do slash.
And then when someone provides the primary key for that to do object.
So we're going to say here that we're looking for an INT and we'll give it the name of P.K. Piqué for
primary key.
And then we're gonna go ahead, move over to our Vieuxtemps pie and create this new class based view.
So we've got to come up with some name here.
I'm going to go ahead and copy what we have for an existing.
To do.
Let's do this to complete list.
So I got a copy this.
And let's paces all the way down here.
OK?
So the generic that we're gonna be using in this case is the retrieve update destroyed.
This is sort of the the big, powerful, powerful one here.
So I got to do my retrieve.
Update.
Destroy covers.
Haul the basics there.
Let's use this same name that we have here so we have to do retrieve, update, destroy.
Let's get rid of API view there, Kay.
So we're still using that to do serializer.
We're still going to make sure that someone signed in for this.
We still need the same query set, except with this one.
We're gonna be very simple here.
We're just gonna say this is going to work for any to do object.
We just want to make sure that it's for the proper user.
We don't need to do any ordering because we're only getting one thing back.
This is literally it.
So with this in place, let's copy this new name that we have here.
Save this Vieux file, come back to our Urals and say, you know, hey, if someone comes to this particular,
you are ellson them to that view class.
Then with that saved, let's go back to our Web site.
And I'm going to move to the API view here.
So we're going to list out all the tattoos.
And look, we just implemented the functionality for this particular to do the idea for.
So let's go to our API.
Slash four.
And oh, we want API slash to dos slash four.
There we go.
And here we can see all the details for this.
So let's say, you know, I have add, update and delete.
Also, I wanted to say add view, update and delete K.
So if I do this, I can do it.
Put.
And it's going to save that information.
Now it's updated there.
We're currently viewing it.
And we have the ability to delete it here.
Now I'm going to go ahead and copy the title of this one because once we delete it, it's not the same
as completing it.
So I'm going to go ahead and hit the delete here to just show you that if we do this, it really is
gone.
And if we go ahead and look back to our list here of the current to DOS, it's no longer there.
It's not inside of our completed.
Like, if we go to our completed here, it's not there either.
It is just deleted.
Right.
Which brings us to a problem here.
And that's that we need to add the ability for someone to complete a to do object.
So I'm going to go ahead and add back.
This to do K so that someone can add, view, update and delete or that's actually not what we want
to do anymore.
We have that functionality.
It's rather we want to complete a to do.
Okay.
So I'm going to post this and now I have.
These two two items left.
Let's go ahead and cover this one in the next lecture.