WEBVTT 00:00.530 --> 00:05.120 Now, in this section, we're going to cover a scenario that I think is probably going to be more common 00:05.120 --> 00:09.980 for your situation, and that's that you have an existing Django project, but you just want to add 00:10.070 --> 00:11.270 an API to it. 00:11.630 --> 00:16.520 So how can you do that now that you have the basics down with the Django rest framework? 00:16.550 --> 00:21.110 Let's learn how to apply it to an existing project and to, you know, make it a little bit quicker 00:21.110 --> 00:23.570 that we don't have to build a whole project from scratch. 00:24.050 --> 00:30.380 I'm going to be providing the code for you from my previous Django three course for this to do app that 00:30.380 --> 00:31.750 we made called to do. 00:31.970 --> 00:32.240 I know. 00:32.270 --> 00:33.420 Really exciting. 00:33.440 --> 00:37.010 And in the previous lecture, you should have gotten the link to go download this. 00:37.040 --> 00:42.980 If not, you can just go to get hub dot com slash zappy code and then go look at the repositories that 00:42.980 --> 00:43.370 I have there. 00:43.370 --> 00:46.700 You're looking for Django three Dash to dash project. 00:47.030 --> 00:52.850 OK, so once you've gone ahead and found this project, you can if you're familiar with get do the get 00:52.850 --> 00:56.110 clone all that good stuff or you can just download the zip code. 00:56.840 --> 01:01.190 And once you've got that, I'm going to go ahead and bring this on to my desktop. 01:02.240 --> 01:04.950 And it's got a little bit of a nasty name here from GitHub. 01:05.320 --> 01:06.980 I'm going to change this to just be. 01:08.150 --> 01:09.110 To do. 01:09.230 --> 01:12.650 Woo dash project a little bit cleaner here. 01:14.090 --> 01:20.210 So with this in place, I want you to get a nice feel for what this app looks like and feels like before 01:20.210 --> 01:21.380 we add an API to it. 01:21.770 --> 01:28.700 So let's go ahead and open up our terminal and move on to our desktop and into our project. 01:29.610 --> 01:29.790 Time. 01:30.620 --> 01:32.570 And let's do an LSC, what's inside of there. 01:32.600 --> 01:34.790 You'll notice that there's already a database. 01:34.850 --> 01:40.580 So I did that on purpose with my previous course so that users could or students could see the users 01:40.580 --> 01:41.750 that are already in the database. 01:41.780 --> 01:43.910 But it's probably a good idea for us to start fresh. 01:44.300 --> 01:49.130 So I'm gonna go in where we have the Escuela database, something going to delete that so that it's 01:49.130 --> 01:49.580 gone. 01:50.120 --> 01:51.960 Let's do an LSC confirm that that's gone. 01:51.980 --> 01:52.400 Great. 01:52.880 --> 02:00.370 So what we need to do now is a migrate song to do my python three managed up pi migrate. 02:01.070 --> 02:01.240 OK. 02:01.370 --> 02:03.800 That gets my database all up to speed. 02:04.310 --> 02:08.540 And then with this let's do a run server. 02:09.740 --> 02:09.960 OK. 02:10.490 --> 02:12.160 So you can see this is up and running now. 02:12.200 --> 02:14.270 Let's go take a peek at what this looks like. 02:15.040 --> 02:16.310 So I want to go to my local host. 02:16.340 --> 02:18.330 Eight thousand and look, here it is. 02:18.350 --> 02:20.430 This is to do so. 02:21.260 --> 02:23.310 Let's go ahead and just see what this looks like. 02:23.330 --> 02:26.150 So I'm going to go ahead and click start here, which is the same as sign up. 02:26.870 --> 02:28.530 I'm going to pick a username like Nick. 02:28.610 --> 02:31.460 And let me go ahead and put in the password here. 02:33.560 --> 02:38.240 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 02:38.240 --> 02:39.610 it's saying, hey, do you want to go make one? 02:39.620 --> 02:40.280 I'll say, sure. 02:41.030 --> 02:46.640 And let's say I want to add an API to my site. 02:47.720 --> 02:49.010 And this is very important. 02:49.010 --> 02:51.010 You can say whether tattoos are important or not. 02:51.020 --> 02:54.830 With that, a little checkmarks I'm going to hit save and look, there's a to do here. 02:54.840 --> 02:57.680 And if you want to see what it looks like to have it to do, that's not urgent. 02:58.160 --> 03:02.720 I can hit create here and make one that says buy cheese. 03:02.720 --> 03:05.500 I got to make sure next time I'm at the grocery store, buy some cheese. 03:05.870 --> 03:11.750 And then, you know, here in the memo I could say, you know, get enough for two pizzas. 03:12.570 --> 03:12.810 Okay. 03:12.960 --> 03:14.070 And I'm going to go and save this. 03:14.090 --> 03:18.010 So now if I go look at my current tattoos, you can see that I've got two here. 03:18.440 --> 03:21.390 And if there's a memo, you can see sort of the preview of that. 03:21.470 --> 03:21.950 Oh, okay. 03:21.980 --> 03:24.590 I got to buy the cheese and make sure that there's enough for two pizzas. 03:25.040 --> 03:30.290 So if either one of these, like with buy cheese, if I have, you know, say, oh, you know what, 03:30.290 --> 03:33.020 I'm actually having more friends over this should be three pizzas. 03:33.560 --> 03:36.470 I can change any information here and hit save. 03:36.680 --> 03:38.390 And what that does is it updates it. 03:38.420 --> 03:40.130 The save is essentially the update. 03:40.580 --> 03:41.660 So now it shows three. 03:41.720 --> 03:42.020 Right. 03:42.140 --> 03:42.860 See that there. 03:43.250 --> 03:47.150 And if we want to, we could just completely get rid of this to do and delete it. 03:47.240 --> 03:48.840 Or we could complete it. 03:48.860 --> 03:53.150 So when I complete it, it's no longer shows up in my current list of to DOS. 03:53.180 --> 03:58.310 But if I go to my completed now, we can see it's there and we can see the exact time that this was 03:58.310 --> 03:58.910 completed. 03:59.360 --> 04:00.230 So kind of cool that. 04:01.160 --> 04:02.540 We can see that information. 04:02.960 --> 04:07.760 So with that, that is essentially to do in a nutshell. 04:07.850 --> 04:11.130 Again, we can log out here and we can also log back in. 04:11.150 --> 04:14.750 So let's do that just to show you that it works. 04:15.970 --> 04:16.470 Look at that. 04:16.810 --> 04:21.870 We're back in this case, so hopefully you've got a good grasp on what this to do. 04:22.160 --> 04:22.370 Whew! 04:22.390 --> 04:23.080 Project is. 04:23.140 --> 04:29.470 And our goal in this section is to add an API for this so that, for example, if someone wanted to 04:29.470 --> 04:35.530 make a mobile app that would, you know, work with two people who had an existing account or wanted 04:35.530 --> 04:40.540 to make a new account, could totally do that from an ISIS app or an Android app. 04:40.960 --> 04:47.110 Whatever it is, we want to have an API available so that our users can use this in, you know, multiple 04:47.110 --> 04:47.640 different ways. 04:47.650 --> 04:52.210 The cool thing about building APIs is that people can do all sorts of amazing things with them. 04:52.210 --> 04:58.360 Speaking of our previous project, the Reddit clone Reddit has a really amazing API that if you've ever 04:58.780 --> 05:05.170 browse the, you know, Google Play or Iooss App Store, there are some amazing mobile apps out there 05:05.170 --> 05:10.960 for Reddit that I feel like routinely are better than the official Reddit app out there. 05:11.170 --> 05:15.880 And that's because, you know, Reddit, I think was so cool to let the API out there and let people 05:15.880 --> 05:16.750 build things for it. 05:18.060 --> 05:18.940 You know, it's kind of the. 05:20.360 --> 05:25.070 If you build it, they will come sort of a thing, if you put the API out there, people make things, 05:25.070 --> 05:29.030 although doesn't exactly match because it's if you build it, they will build it. 05:29.450 --> 05:30.770 I'm starting to ramble here. 05:30.770 --> 05:34.680 So let's go ahead and start diving into the code now.