Now, in this section, we're going to cover a scenario that I think is probably going to be more common
for your situation, and that's that you have an existing Django project, but you just want to add
an API to it.
So how can you do that now that you have the basics down with the Django rest framework?
Let's learn how to apply it to an existing project and to, you know, make it a little bit quicker
that we don't have to build a whole project from scratch.
I'm going to be providing the code for you from my previous Django three course for this to do app that
we made called to do.
I know.
Really exciting.
And in the previous lecture, you should have gotten the link to go download this.
If not, you can just go to get hub dot com slash zappy code and then go look at the repositories that
I have there.
You're looking for Django three Dash to dash project.
OK, so once you've gone ahead and found this project, you can if you're familiar with get do the get
clone all that good stuff or you can just download the zip code.
And once you've got that, I'm going to go ahead and bring this on to my desktop.
And it's got a little bit of a nasty name here from GitHub.
I'm going to change this to just be.
To do.
Woo dash project a little bit cleaner here.
So with this in place, I want you to get a nice feel for what this app looks like and feels like before
we add an API to it.
So let's go ahead and open up our terminal and move on to our desktop and into our project.
Time.
And let's do an LSC, what's inside of there.
You'll notice that there's already a database.
So I did that on purpose with my previous course so that users could or students could see the users
that are already in the database.
But it's probably a good idea for us to start fresh.
So I'm gonna go in where we have the Escuela database, something going to delete that so that it's
gone.
Let's do an LSC confirm that that's gone.
Great.
So what we need to do now is a migrate song to do my python three managed up pi migrate.
OK.
That gets my database all up to speed.
And then with this let's do a run server.
OK.
So you can see this is up and running now.
Let's go take a peek at what this looks like.
So I want to go to my local host.
Eight thousand and look, here it is.
This is to do so.
Let's go ahead and just see what this looks like.
So I'm going to go ahead and click start here, which is the same as sign up.
I'm going to pick a username like Nick.
And let me go ahead and put in the password here.
So I've signed up for a new user, Nick, it's got me logged in here, I don't have any to DOS, but
it's saying, hey, do you want to go make one?
I'll say, sure.
And let's say I want to add an API to my site.
And this is very important.
You can say whether tattoos are important or not.
With that, a little checkmarks I'm going to hit save and look, there's a to do here.
And if you want to see what it looks like to have it to do, that's not urgent.
I can hit create here and make one that says buy cheese.
I got to make sure next time I'm at the grocery store, buy some cheese.
And then, you know, here in the memo I could say, you know, get enough for two pizzas.
Okay.
And I'm going to go and save this.
So now if I go look at my current tattoos, you can see that I've got two here.
And if there's a memo, you can see sort of the preview of that.
Oh, okay.
I got to buy the cheese and make sure that there's enough for two pizzas.
So if either one of these, like with buy cheese, if I have, you know, say, oh, you know what,
I'm actually having more friends over this should be three pizzas.
I can change any information here and hit save.
And what that does is it updates it.
The save is essentially the update.
So now it shows three.
Right.
See that there.
And if we want to, we could just completely get rid of this to do and delete it.
Or we could complete it.
So when I complete it, it's no longer shows up in my current list of to DOS.
But if I go to my completed now, we can see it's there and we can see the exact time that this was
completed.
So kind of cool that.
We can see that information.
So with that, that is essentially to do in a nutshell.
Again, we can log out here and we can also log back in.
So let's do that just to show you that it works.
Look at that.
We're back in this case, so hopefully you've got a good grasp on what this to do.
Whew!
Project is.
And our goal in this section is to add an API for this so that, for example, if someone wanted to
make a mobile app that would, you know, work with two people who had an existing account or wanted
to make a new account, could totally do that from an ISIS app or an Android app.
Whatever it is, we want to have an API available so that our users can use this in, you know, multiple
different ways.
The cool thing about building APIs is that people can do all sorts of amazing things with them.
Speaking of our previous project, the Reddit clone Reddit has a really amazing API that if you've ever
browse the, you know, Google Play or Iooss App Store, there are some amazing mobile apps out there
for Reddit that I feel like routinely are better than the official Reddit app out there.
And that's because, you know, Reddit, I think was so cool to let the API out there and let people
build things for it.
You know, it's kind of the.
If you build it, they will come sort of a thing, if you put the API out there, people make things,
although doesn't exactly match because it's if you build it, they will build it.
I'm starting to ramble here.
So let's go ahead and start diving into the code now.