WEBVTT 00:02.720 --> 00:08.150 In this lesson we're going to keep working on duty education system for our project creating all the 00:08.150 --> 00:14.630 templates that are needed to authenticate users of your browser and tweaking all the settings that are 00:14.630 --> 00:19.540 in fact important to set up an authentication system with Django Django this framework. 00:19.640 --> 00:25.820 And considering that as you can see I'm currently inside these settings that profile we can start adding 00:25.820 --> 00:26.990 all the settings from here. 00:27.410 --> 00:32.830 Let's define the rest framework dictionary. 00:33.560 --> 00:42.860 And yet I cannot comment Django rest framework and inside of this dictionary you can define a very important 00:42.890 --> 00:48.770 key default authentication classes that as we've seen in the previous sections of the course allows 00:48.770 --> 00:53.480 us to define how we want our users to interact with our platform. 00:53.480 --> 00:59.420 We know that we want to be able to authenticate themself using both token authentication and session 00:59.420 --> 01:00.500 authentication. 01:00.500 --> 01:12.410 Therefore we can define default authentication classes and yet we can assign a tuple like so with rest 01:13.070 --> 01:20.330 framework that authentication dot token authentication. 01:21.470 --> 01:31.370 And at the same time also let's trademark dot authentication dot session authentication. 01:31.370 --> 01:34.990 Now we can define our location for our templates. 01:35.000 --> 01:43.140 So I'm just going to copy this line of code I can paste it here in directories and templates and yeah 01:43.190 --> 01:50.240 we can tell Django that it has to look for the templates templates folder let's create the folder. 01:50.240 --> 01:50.600 So 01:55.050 --> 02:02.680 new folder templates and inside of this folder we now need to create two more folders one called Django 02:03.740 --> 02:10.490 registration where we're going to define all the templates required by the opening package and then 02:10.520 --> 02:18.070 we can create another folder just called registration where by default we stored all the logging related 02:18.080 --> 02:24.020 templates used by Django considering that we want all the authentication related templates to share 02:24.080 --> 02:25.250 a common layout. 02:25.310 --> 02:32.370 We can create yet in the folder itself of a yellow dot HDMI file. 02:32.510 --> 02:36.050 We can add all the basic HDMI all boilerplate code. 02:36.110 --> 02:48.690 We can add question time as a title for the page and yet we can also define a diva with class of boxer. 02:48.950 --> 02:55.310 And considering that we want this to be a parent template we can add block content. 02:55.820 --> 03:06.140 And of course and block let let's also have the link to a CDM providing bootstrap and I remember you 03:06.140 --> 03:09.560 did you can find this link at the address get bootstrap dot com. 03:09.560 --> 03:12.360 We can start to create all the other templates that we need. 03:12.380 --> 03:23.600 First of all logging and Dot is the email and we are extending so extends of layout not finish the email. 03:23.720 --> 03:28.880 We also need to pass blog content and block content. 03:28.880 --> 03:37.470 So as Dan Harris side we can define for example in H1 tag logging the Dan form and we only need the 03:37.550 --> 03:47.240 method POST AND WELL IN FACT WE CAN ALSO encapsulate the for inside of a different like so. 03:47.460 --> 03:58.860 And here to leave we can also add a class I mean like looking for container and considering that we 03:58.860 --> 04:05.820 are using the logging views provided by Django we can get all the fields for the form easily like so 04:06.030 --> 04:06.950 as always. 04:07.140 --> 04:20.800 Anyways it always we need to pass the C S at f token and you also need to define a bottom of type submitted. 04:21.900 --> 04:28.650 And considering that we're using Bootstrap we can add a glass bottle bottles small button primary or 04:28.650 --> 04:38.340 even by the bottom outline primary and we're looking as you probably remember we're also using a package 04:38.340 --> 04:46.120 called Django goodies before items that allows us to create good looking forums easily based on the 04:46.120 --> 04:49.920 style that we've defined yet in the case B template back option. 04:50.360 --> 04:59.660 And so to use them we can just yet important first of all the crispy forums tax load Krispie forms. 04:59.710 --> 05:00.210 Thanks. 05:00.850 --> 05:09.530 And here we can just use that crispy tag let's define a bit of style for our log in form container Classic 05:09.720 --> 05:13.560 we will then add all the more advanced styling later on. 05:13.650 --> 05:24.570 So for now can do something like looking for a container India we can define it with of that says with 05:24.830 --> 05:32.160 margin outlook we can in fact also move the title tag above. 05:32.160 --> 05:38.700 Like so and considering that we are using Bootstrap we can also add the text center. 05:38.940 --> 05:47.130 So let's not create the other form that we need inside the Django registration folder registration form 05:47.220 --> 05:55.350 dot h the email and we can just copy all the code used in logging that HDMI up but of course we can 05:55.350 --> 06:09.460 personalize it so maybe we can use an H3 with create your question time account and yeah create account. 06:09.660 --> 06:16.230 Then also we can change the CSX class name to registration form container. 06:16.230 --> 06:25.400 So let's move these two awfully out so we can just copy the same CSA as code. 06:25.670 --> 06:28.920 But yeah maybe we can define 400 pixels instead. 06:29.150 --> 06:32.930 We can try all these new code we've defined so let's run the development server 06:37.060 --> 06:44.140 and let's now move to Chrome so we can test the new you URL but first of all let's check the registration 06:44.140 --> 06:53.110 path so it's less account is less registered and you see we get our form which is also nicely styled 06:53.500 --> 06:55.500 by Django Gris before us. 06:55.520 --> 07:07.590 Let's register in your account username maybe random random email does come and set password create 07:07.600 --> 07:13.950 account and as you can see we are automatically redirected to the home page even though we haven't specified 07:14.040 --> 07:16.180 any view for this path yet. 07:16.590 --> 07:22.860 And to check if we have been authenticated or not we can go to less admin and as you can see we are 07:22.950 --> 07:37.320 authenticated as random let's not go to slash accounts slash log in and let's log in as admin and now 07:37.320 --> 07:46.740 going back to flesh and mean we can see that everything works fine here as well as we can see everything 07:46.740 --> 07:52.970 related to authentication of your browser works perfectly as expected and to be fair I believe that 07:52.980 --> 07:56.250 talking authentication is working fine just as well. 07:56.380 --> 08:01.200 We're going to check it any way later on as soon as the backend structure is completed.