WEBVTT

00:00.740 --> 00:07.670
Okay, In this video, we will create our routing and we'll create URLs.

00:07.670 --> 00:13.820
So we have our application here now and we have URLs here.

00:13.820 --> 00:22.250
I can remove that and comment for now and we'll have at the moment simple admin here and that's our

00:22.250 --> 00:23.450
path to admin.

00:23.450 --> 00:29.240
But what we can do is we can actually add our second URL level.

00:29.240 --> 00:38.570
So I will create a new file and I will name it urls.py and that will be URL for our API here at the

00:38.570 --> 00:38.900
moment.

00:38.900 --> 00:42.290
I will just copy that and paste it here.

00:42.290 --> 00:45.800
So that will be, let's name it for a moment new.

00:45.830 --> 00:47.960
That is just a placeholder.

00:48.170 --> 00:51.080
So I will have a new file to refer to.

00:51.110 --> 00:57.980
So what I can do here is I can add another path, so I will duplicate the whole line.

00:57.980 --> 01:05.430
I clicked command D So that's duplicating the whole line and the new path is API.

01:05.730 --> 01:12.960
So whatever we will go to API, we want to include our URL from the API URLs.

01:12.960 --> 01:14.820
We need to import that first.

01:14.820 --> 01:26.220
So from Django Django conf urls we will import.

01:28.700 --> 01:33.680
Include and that include we can use here.

01:33.680 --> 01:41.890
So include and then we can do include API URLs like that.

01:41.900 --> 01:43.610
So what else we need to do?

01:43.640 --> 01:48.050
We from here we refer to admin or to API.

01:48.320 --> 01:54.320
What we need to do is we need to register also our API in installed apps.

01:54.320 --> 02:02.510
So we need to do actually two things so we haven't register rest framework yet, framework like that

02:02.510 --> 02:07.910
and we can register our application, which is API as you can see here.

02:08.180 --> 02:15.800
So once I have that in the installed apps, I will need to also go to terminal and I will do Python

02:16.370 --> 02:20.030
three Manage.py migrate.

02:21.700 --> 02:23.140
Not to apply.

02:23.170 --> 02:24.210
Everything is good.

02:24.220 --> 02:26.850
If you have something, then it will be applied.

02:26.860 --> 02:30.700
Then we have this admin and we have API.

02:30.730 --> 02:33.040
If I go here now.

02:35.440 --> 02:39.220
You can see here two parts are available admin and API.

02:39.250 --> 02:48.550
So admin is working as it was before and then api, I can go here and the API slash and you can see

02:48.550 --> 02:52.210
here that new is available already for us.

02:52.210 --> 02:57.760
And at the moment it's just a placeholder because we don't have anything here to display, but we will

02:57.790 --> 03:06.820
build a new models and new things later on and we can create a router for now and we can actually fill

03:06.820 --> 03:07.810
it later on.

03:07.810 --> 03:09.820
So what else is missing?

03:09.820 --> 03:12.070
We haven't created our super user.

03:12.310 --> 03:21.460
We can go to terminal and we can do Python3 Manage.py and then create super user.

03:23.560 --> 03:29.860
And I can leave it blank to Christian and an email address.

03:29.860 --> 03:31.060
I will leave it blank.

03:31.270 --> 03:34.450
So just enter and I will use Christian.

03:34.900 --> 03:38.580
Very unsecure, but I don't mind.

03:38.590 --> 03:42.220
And this is how yes I would like to keep it.

03:42.220 --> 03:48.850
So my username and password is Christian, but please pick something more more secure because if you

03:48.850 --> 03:55.840
at any point will put it on production and someone will discover the username and password, then it

03:55.840 --> 03:58.690
will have an access to all your application.

03:58.690 --> 04:04.300
And remember that creating super user, you create a user with all permissions.

04:04.300 --> 04:06.550
So that might be very dangerous.

04:06.790 --> 04:11.770
Uh, for this tutorial, I don't really care about the security because this is not a live application

04:11.770 --> 04:13.870
and it will never be so Christian.

04:13.870 --> 04:16.270
Christian is just easy to remember in use.

04:17.110 --> 04:22.570
Okay, so we have our user, then we can use our Django here.

04:22.570 --> 04:24.740
What I can do is admin.

04:25.980 --> 04:27.150
And then Christian.

04:27.150 --> 04:29.160
Christian, I can log in.

04:29.190 --> 04:32.910
You can see here everything is kind of working.

04:32.910 --> 04:35.310
So we have our URLs.

04:35.310 --> 04:41.460
So let's build our router and we'll have it ready for later use.

04:41.460 --> 04:45.660
So what we need to do is from rest framework.

04:47.230 --> 04:50.050
Import routers.

04:50.200 --> 04:54.490
And then we can create our router router.

04:58.210 --> 05:02.440
Router's default router here.

05:02.440 --> 05:06.610
And then later on we can actually register some of the models.

05:06.610 --> 05:08.890
At the moment we don't have any models register.

05:08.890 --> 05:12.160
So what we can do is we can only push it to part.

05:13.860 --> 05:23.840
So we will make an empty pad and then we can do include and actually we need to.

05:24.960 --> 05:27.930
Import include the same way as we've done here.

05:27.930 --> 05:29.400
So we'll just copy this.

05:31.400 --> 05:40.070
And that include will include our router router.

05:42.470 --> 05:44.330
URLs like that.

05:44.510 --> 05:50.870
So whatever we will have here, register on the router, it will be available there.

05:50.900 --> 05:53.330
So our URLs are set up.

05:53.330 --> 05:58.370
We have everything written and prepared for us to use.

05:58.370 --> 06:03.080
So in the next video we'll start actually building our data.

06:03.080 --> 06:04.820
So we'll need to create models.

06:04.820 --> 06:09.590
We'll need to create serializers, we'll also need to create views.

06:09.590 --> 06:12.890
So we'll be doing that in the next videos.
