1 00:00:00,330 --> 00:00:03,012 Previously we created this HTML template, which 2 00:00:03,013 --> 00:00:05,690 should be served to a particular URL. 3 00:00:05,691 --> 00:00:11,433 So let's define the URL, where this page will be served. 4 00:00:11,754 --> 00:00:13,920 For that we want to do two things. 5 00:00:15,010 --> 00:00:18,160 First thing is we want to go to mysite, 6 00:00:19,330 --> 00:00:23,706 so the project configuration files and go to urls.py. 7 00:00:23,707 --> 00:00:26,972 And here, now we want to add a new 8 00:00:26,973 --> 00:00:30,098 urlpattern, for the new app that we added. 9 00:00:30,099 --> 00:00:33,346 So we have urlpatterns for the admin interface, 10 00:00:33,347 --> 00:00:36,476 we have a urlpattern for the blog app. 11 00:00:36,477 --> 00:00:38,550 Now we want to add a new item. 12 00:00:38,551 --> 00:00:41,450 So make a comma after the last item 13 00:00:42,110 --> 00:00:45,290 and then a new row and say path. 14 00:00:45,300 --> 00:00:47,470 [No Audio] 15 00:00:47,471 --> 00:00:53,300 Now this part here, is what comes after the domain name. 16 00:00:53,301 --> 00:00:56,640 So if our domain name is example.com, 17 00:00:57,490 --> 00:01:02,874 then we say translate with a slash. 18 00:01:02,875 --> 00:01:05,111 That means now, that our app 19 00:01:05,112 --> 00:01:09,666 will be served on example.com/translate/. 20 00:01:10,310 --> 00:01:16,530 A comma include, and inside the parentheses 21 00:01:16,531 --> 00:01:22,130 we say translator, without the slash. 22 00:01:22,131 --> 00:01:25,532 So this is the name of our app, which 23 00:01:25,533 --> 00:01:28,918 you can find, as the name of the folder 24 00:01:28,919 --> 00:01:35,782 containing all the files. .urls which is a file, 25 00:01:35,783 --> 00:01:40,550 that should be now inside your translator folder. 26 00:01:40,551 --> 00:01:43,882 So by default there isn't such a file. 27 00:01:43,883 --> 00:01:49,399 So right click and go to New File and say urls.py. 28 00:01:49,400 --> 00:01:52,130 [No Audio] 29 00:01:52,131 --> 00:01:55,294 Now here we define the other urls, 30 00:01:55,295 --> 00:01:58,710 because one app could contain multiple pages. 31 00:01:58,711 --> 00:02:03,176 So in the main, in this url here, we define only 32 00:02:03,177 --> 00:02:09,681 one, which contains the upper level part of the url. 33 00:02:09,682 --> 00:02:14,876 So let's say we have example.com/translate and then 34 00:02:14,877 --> 00:02:21,233 we could have, other pages such as example.com/translate/ 35 00:02:21,233 --> 00:02:29,488 whatever, then another page example.com/translate get or do or 36 00:02:29,489 --> 00:02:32,234 be whatever you have after translate. 37 00:02:32,235 --> 00:02:34,986 But every one of these pages 38 00:02:34,987 --> 00:02:37,556 will contain that translate part. 39 00:02:37,557 --> 00:02:43,124 So this is what we define here, the first door to our app. 40 00:02:43,125 --> 00:02:47,128 After that door, there will be other doors which 41 00:02:47,129 --> 00:02:52,070 we have to define in, the other urls here. 42 00:02:52,071 --> 00:02:58,642 So let's go to blog and copy urls of blog. 43 00:02:58,643 --> 00:03:01,690 So this one in here and then go to 44 00:03:01,691 --> 00:03:05,068 the new urls of Translator, and just paste it 45 00:03:05,069 --> 00:03:07,196 here, so we don't have to type again. 46 00:03:07,197 --> 00:03:10,866 So I don't think this is relevant this time the slug, 47 00:03:12,078 --> 00:03:16,592 because we will not be creating blog posts, which 48 00:03:16,593 --> 00:03:20,198 will have this slug, defined by the contents creator. 49 00:03:20,199 --> 00:03:21,920 So I'm going to delete that. 50 00:03:22,530 --> 00:03:26,388 And now, what do we want to have? 51 00:03:26,389 --> 00:03:30,420 So for example, this one here, if you have 52 00:03:30,421 --> 00:03:34,472 this empty string, that means this view is going 53 00:03:34,473 --> 00:03:39,742 to render an html template directly in translate. 54 00:03:39,743 --> 00:03:43,214 So example.com/translate. 55 00:03:43,215 --> 00:03:45,342 But if you want something after the translator 56 00:03:45,343 --> 00:03:48,092 as we said, you want to write something. 57 00:03:48,093 --> 00:03:51,196 So I'm going to delete one of these 58 00:03:51,197 --> 00:03:53,666 and just keep it an empty string. 59 00:03:53,667 --> 00:03:58,231 So when the user goes to example.com/translate/ 60 00:03:58,232 --> 00:04:03,310 one of our views will be responsible to handle that request. 61 00:04:03,311 --> 00:04:07,466 So let's call this translator 62 00:04:07,467 --> 00:04:09,466 [Author Typing] 63 00:04:09,467 --> 00:04:16,372 _view, we're going to write normal views which 64 00:04:16,373 --> 00:04:19,600 means that, these views will be functions. 65 00:04:20,050 --> 00:04:24,014 So by default, Python works with functions as views. 66 00:04:24,015 --> 00:04:27,150 And this is easier to work with forms. 67 00:04:27,151 --> 00:04:31,528 Therefore, we don't need that as_view function 68 00:04:31,529 --> 00:04:33,860 here, because this is actually a view. 69 00:04:34,630 --> 00:04:36,566 translator_view is a view but, 70 00:04:36,733 --> 00:04:40,306 before, those classes were not views. 71 00:04:40,307 --> 00:04:42,610 That's why we had to transform 72 00:04:42,611 --> 00:04:44,626 them, convert them to views. 73 00:04:44,627 --> 00:04:48,194 Alright, then, a name for this url. 74 00:04:48,195 --> 00:04:52,970 Let's give it the name of translator_view. 75 00:04:52,971 --> 00:04:54,524 So save that. 76 00:04:54,525 --> 00:04:58,076 And with those two configurations, we are 77 00:04:58,077 --> 00:05:01,748 ready to create our translator_view, view. 78 00:05:01,749 --> 00:05:04,033 So let's create that in the next video, see you.