{"id":326591,"date":"2021-07-17T15:00:24","date_gmt":"2021-07-17T15:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326591"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326591","title":{"rendered":"\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 Django Class-based views"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gj\/ae\/yi\/gjaeyifgnbq34shcjtpejcddpgc.png\" width=\"1560\" height=\"880\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 Django, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u043c\u0430\u0433\u0438\u044e \u0447\u0451\u0440\u043d\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0443 \u043c\u0435\u043d\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0435 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435. \u041e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u044f\u0449\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u0432\u0430\u0441, \u043d\u043e \u043d\u0435 \u0434\u0430\u044e\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u042f \u0445\u043e\u0447\u0443 \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0437\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u043a\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0438, Class-based views \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0443\u0433\u0430\u044e\u0449\u0438\u043c\u0438 \u0438 \u044f \u043f\u043e\u0434\u0441\u0442\u0435\u0433\u043d\u0443 \u0432\u0430\u0441 \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0434\u0443\u043c\u0430\u043b\u0438 \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u043a\u0430\u043a \u043e \u043d\u0435\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438.<\/p>\n<hr>\n<h3>Background<\/h3>\n<p>\u042f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0443 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431 \u041e\u041e\u041f \u0432 Python \u0438 \u043e\u043f\u044b\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u043c\u0430\u043c\u0438: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/482464\/\" rel=\"noopener noreferrer nofollow\"><u>*args \u0438 **kwargs<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=wKyUZY4-Dxc\" rel=\"noopener noreferrer nofollow\"><u>\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f<\/u><\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/141411\/\" rel=\"noopener noreferrer nofollow\"><u>\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/u><\/a><\/p>\n<\/li>\n<li>\n<p>@classmethod<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/62203\/\" rel=\"noopener noreferrer nofollow\"><u>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 MRO<\/u><\/a>, \u043c\u0438\u043a\u0441\u0438\u043d\u044b<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=61UuKJRl2m0\" rel=\"noopener noreferrer nofollow\"><u>\u0424\u0443\u043d\u043a\u0446\u0438\u044f super()<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u044f \u0432\u043e\u0437\u044c\u043c\u0443 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 <code>AboutView<\/code>, \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 <code>TemplateView<\/code>, \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0436\u0438\u0437\u043d\u044c \u043a\u043b\u0430\u0441\u0441\u0430: \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u0440\u0435\u0434\u043a\u0438, \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0432\u044b\u0437\u043e\u0432 \u0438\u0437 URLConf, \u043f\u0440\u0438\u043c\u0435\u0441\u0438 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<pre><code class=\"python\"> class AboutView(TemplateView):     template_name = \"about.html\"<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u044f \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043c\u044b\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e. \u0414\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f, \u0438 \u043e\u043a\u0438\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u043d\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c. <\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/df\/az\/64\/dfaz64itpmagwlg9y_w5g01t-as.png\" width=\"2041\" height=\"2646\"><figcaption><\/figcaption><\/figure>\n<\/div>\n<\/details>\n<h2>0. URL dispatcher<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Django \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/topics\/http\/urls\/#how-django-processes-a-request\" rel=\"noopener noreferrer nofollow\">\u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 URL<\/a>: \u043e\u043d \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 URL c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u0438, \u043d\u0430\u0445\u043e\u0434\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 HttpRequest \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b <code>urlpatterns<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e Function-based&nbsp;View&nbsp;(FBV) \u0438 \u043d\u0430 Class-based&nbsp;View&nbsp;(CBV):<\/p>\n<pre><code class=\"python\">urlpatterns = [     # Function-based View     path('about\/', about),      # Class-based View     path('about\/', AboutView.as_view()), ]<\/code><\/pre>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043e\u0442\u043b\u0438\u0447\u0438\u0435: \u0432 <abbr title=\"Function-based&nbsp;View\">FBV<\/abbr> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>about<\/code>, \u0430 \u043d\u0435 <code>about()<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0451 (\u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440). \u0410 \u0432 <abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u2014 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 <code>.as_view()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c\u0438. \u041d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0438, \u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043a\u0430 \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 TemplateView<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">class TemplateView(TemplateResponseMixin, ContextMixin, View):     \"\"\"     Render a template. Pass keyword arguments from the URLconf to the context.     \"\"\"     def get(self, request, *args, **kwargs):         context = self.get_context_data(**kwargs)         return self.render_to_response(context)<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0436\u0435 \u043e\u043d \u0432\u0437\u044f\u043b\u0441\u044f? \u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u044e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f <code>AboutView<\/code>.<\/p>\n<h2>1. Class View<\/h2>\n<p><abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u043e\u0432, \u043d\u043e \u0432\u0441\u0435 <abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u0431\u0435\u0440\u0443\u0442 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code>. \u041d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/b0\/4d\/wi\/b04dwiw2rx3w0vwfupu68xe1zle.png\" alt=\"\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 AboutView\" title=\"\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 AboutView\" width=\"780\" height=\"394\"><figcaption>\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 AboutView<\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434&nbsp;View:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 View<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">class View:     \"\"\"     Intentionally simple parent class for all views. Only implements     dispatch-by-method and simple sanity checking.     \"\"\"      http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']      def __init__(self, **kwargs):         \"\"\"         Constructor. Called in the URLconf; can contain helpful extra         keyword arguments, and other things.         \"\"\"         # Go through keyword arguments, and either save their values to our         # instance, or raise an error.         for key, value in kwargs.items():             setattr(self, key, value)      @classonlymethod     def as_view(cls, **initkwargs):         \"\"\"Main entry point for a request-response process.\"\"\"         for key in initkwargs:             if key in cls.http_method_names:                 raise TypeError(                     'The method name %s is not accepted as a keyword argument '                     'to %s().' % (key, cls.__name__)                 )             if not hasattr(cls, key):                 raise TypeError(\"%s() received an invalid keyword %r. as_view \"                                 \"only accepts arguments that are already \"                                 \"attributes of the class.\" % (cls.__name__, key))          def view(request, *args, **kwargs):             self = cls(**initkwargs)             self.setup(request, *args, **kwargs)             if not hasattr(self, 'request'):                 raise AttributeError(                     \"%s instance has no 'request' attribute. Did you override \"                     \"setup() and forget to call super()?\" % cls.__name__                 )             return self.dispatch(request, *args, **kwargs)         view.view_class = cls         view.view_initkwargs = initkwargs          # take name and docstring from class         update_wrapper(view, cls, updated=())          # and possible attributes set by decorators         # like csrf_exempt from dispatch         update_wrapper(view, cls.dispatch, assigned=())         return view      def setup(self, request, *args, **kwargs):         \"\"\"Initialize attributes shared by all view methods.\"\"\"         if hasattr(self, 'get') and not hasattr(self, 'head'):             self.head = self.get         self.request = request         self.args = args         self.kwargs = kwargs      def dispatch(self, request, *args, **kwargs):         # Try to dispatch to the right method; if a method doesn't exist,         # defer to the error handler. Also defer to the error handler if the         # request method isn't on the approved list.         if request.method.lower() in self.http_method_names:             handler = getattr(self, request.method.lower(), self.http_method_not_allowed)         else:             handler = self.http_method_not_allowed         return handler(request, *args, **kwargs)      def http_method_not_allowed(self, request, *args, **kwargs):         logger.warning(             'Method Not Allowed (%s): %s', request.method, request.path,             extra={'status_code': 405, 'request': request}         )         return HttpResponseNotAllowed(self._allowed_methods())      def options(self, request, *args, **kwargs):         \"\"\"Handle responding to requests for the OPTIONS HTTP verb.\"\"\"         response = HttpResponse()         response.headers['Allow'] = ', '.join(self._allowed_methods())         response.headers['Content-Length'] = '0'         return response      def _allowed_methods(self):         return [m.upper() for m in self.http_method_names if hasattr(self, m)]<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0435, \u043d\u043e \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 Django.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 URLConf \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>as_view()<\/code>, \u043f\u0440\u0438\u043c\u0435\u043c \u0435\u0433\u043e \u0437\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043f\u043e\u0438\u0441\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 <abbr title=\"Method Resolution Order\">MRO<\/abbr> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>View<\/code>:<\/p>\n<pre><code class=\"python\">    @classonlymethod     def as_view(cls, **initkwargs):         \"\"\"Main entry point for a request-response process.\"\"\"         for key in initkwargs:             if key in cls.http_method_names:                 raise TypeError(                     'The method name %s is not accepted as a keyword argument '                     'to %s().' % (key, cls.__name__)                 )             if not hasattr(cls, key):                 raise TypeError(\"%s() received an invalid keyword %r. as_view \"                                 \"only accepts arguments that are already \"                                 \"attributes of the class.\" % (cls.__name__, key))          def view(request, *args, **kwargs):             # \u0437\u0434\u0435\u0441\u044c \u0431\u044b\u043b \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 view, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d                      view.view_class = cls         view.view_initkwargs = initkwargs          # take name and docstring from class         update_wrapper(view, cls, updated=())          # and possible attributes set by decorators         # like csrf_exempt from dispatch         update_wrapper(view, cls.dispatch, assigned=())         return view<\/code><\/pre>\n<p>\u0412 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f: \u0432\u043e\u2011\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@classonlymethod<\/code> \u0438\u0437 <code>django.utils.decorators<\/code> \u2014 \u043f\u043e\u0442\u043e\u043c\u043e\u043a <code>builtins.classmethod<\/code>. \u0418\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432\u043e\u0437\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>AttributeError<\/code>.<\/p>\n<p>\u0412\u043e\u2011\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 <code>**kwargs<\/code> \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 <code>**initkwargs<\/code> \u2014 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435\u0441\u043f\u0440\u043e\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0438\u0436\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f view \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>**kwargs<\/code> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0415\u0441\u043b\u0438 \u0431\u044b \u0438\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 <code>**kwargs<\/code> \u0437\u0430\u0442\u0435\u043d\u0438\u043b \u0431\u044b \u0432\u043d\u0435\u0448\u043d\u0438\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f. \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u0438\u043c\u044f \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u043e\u043b\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 <code>**<\/code> \u2014 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c .<\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 <code>**initkwargs<\/code>? \u041f\u043e \u0437\u0430\u0434\u0443\u043c\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 Django, \u0432 <code>as_view<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <code>AboutView<\/code> \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"python\">path('about\/', TemplateView.as_view(template_name=\"about.html\"))<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>initkwargs = {'template_name': 'about.html'}<\/code>.<\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 \u0434\u0430\u043b\u044c\u0448\u0435. \u0412 \u0446\u0438\u043a\u043b\u0435 for \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0438 <code>initkwargs<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u0432\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"python\">for key in initkwargs:     if key in cls.http_method_names:         raise TypeError(             'The method name %s is not accepted as a keyword argument '             'to %s().' % (key, cls.__name__)         )<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 HTTP\u2011\u0433\u043b\u0430\u0433\u043e\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 (\u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>http_method_names<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code>)<\/p>\n<pre><code class=\"python\">http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']<\/code><\/pre>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u044b \u0432 \u0447\u0435\u0441\u0442\u044c HTTP\u2011\u0433\u043b\u0430\u0433\u043e\u043b\u043e\u0432, \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 (\u0442.\u0435. \u043c\u0435\u0442\u043e\u0434 <code>get()<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 c \u043c\u0435\u0442\u043e\u0434\u043e\u043c GET), \u043c\u044b \u044d\u0442\u043e \u0435\u0449\u0451 \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430: <\/p>\n<pre><code class=\"python\">    if not hasattr(cls, key):         raise TypeError(\"%s() received an invalid keyword %r. as_view \"                         \"only accepts arguments that are already \"                         \"attributes of the class.\" % (cls.__name__, key))<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c Python \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 <abbr title=\"Method Resolution Order\">MRO<\/abbr> \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0438, \u0435\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0438 \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0438\u0445, \u0432\u043e\u0437\u0431\u0443\u0436\u0434\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>TypeError<\/code>.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u0441\u044f \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>view()<\/code>, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u0432\u0430\u0436\u043d\u044b, \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043d\u0435\u0439 \u043f\u043e\u0437\u0436\u0435. \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>view<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>function<\/code>.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a <code>view<\/code> \u0434\u0432\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430: <code>.view_class<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <code>AboutView<\/code> \u0438 <code>.view_initkwargs<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c <code>initkwargs<\/code>:<\/p>\n<pre><code class=\"python\">view.view_class = cls view.view_initkwargs = initkwargs<\/code><\/pre>\n<p>\u0438 \u043f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 wrapper-\u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\"># take name and docstring from class update_wrapper(view, cls, updated=())  # and possible attributes set by decorators # like csrf_exempt from dispatch update_wrapper(view, cls.dispatch, assigned=())<\/code><\/pre>\n<p>\u0422\u0435, \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>as_view<\/code> \u043a\u0430\u043a \u0440\u0430\u0437 \u0438\u043c \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>view<\/code>. \u0412\u0440\u0430\u043f\u043f\u0435\u0440\u044b \u2014 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043a\u043e\u0434 \u0432\u0440\u0430\u043f\u043f\u0435\u0440\u0430, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b <code>__module__<\/code>, <code>__name__<\/code>, <code>__qualname__<\/code>, <code>__doc__<\/code>, <code>__annotations__<\/code> \u0438 <code>__dict__<\/code> \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 <code>AboutView <\/code>\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>.dispatch<\/code> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>View<\/code>.<\/p>\n<pre><code class=\"python\">WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__qualname__', '__doc__',                        '__annotations__') WRAPPER_UPDATES = ('__dict__',)  def update_wrapper(wrapper,                    wrapped,                    assigned = WRAPPER_ASSIGNMENTS,                    updated = WRAPPER_UPDATES):     for attr in assigned:         try:             value = getattr(wrapped, attr)         except AttributeError:             pass         else:             setattr(wrapper, attr, value)     for attr in updated:         getattr(wrapper, attr).update(getattr(wrapped, attr, {}))     wrapper.__wrapped__ = wrapped     return wrapper<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 <code>as_view<\/code> \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0448\u043f\u0438\u0433\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>view<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 URLConf. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441 URLConf \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\"># Class-based View path('about\/', &lt;function AboutView&gt;)<\/code><\/pre>\n<p> , \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 FBV. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043b \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 web-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 URL \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>view<\/code>&#8230;<\/p>\n<h2>2. View function<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f view \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0434\u0438\u0440\u0438\u0436\u0451\u0440\u043e\u043c: \u043e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 response. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">def view(request, *args, **kwargs):     self = cls(**initkwargs)     self.setup(request, *args, **kwargs)     if not hasattr(self, 'request'):         raise AttributeError(             \"%s instance has no 'request' attribute. Did you override \"             \"setup() and forget to call super()?\" % cls.__name__         )     return self.dispatch(request, *args, **kwargs)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0440\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f <code>request<\/code> \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>WSGIRequest<\/code>, \u0434\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>*args<\/code> \u0438 <code>**kwargs<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 URL \u0430\u0434\u0440\u0435\u0441\u0430 . \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"python\">path('articles\/&lt;slug:title&gt;\/&lt;int:section&gt;\/', views.section, ) # \u0417\u0430\u043f\u0440\u043e\u0441 URL www.smth.ru\/articles\/foobar\/3 # \u0432\u0435\u0440\u043d\u0451\u0442 kwargs = {'title': 'foobar', 'section': 3}<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u0430\u0442\u044c <code>**kwargs<\/code> \u0441<code>**initkwargs<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435: \u0432 <code>**initkwargs<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0434\u043b\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0432 <code>**kwargs<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 URL \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f view \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 <code>**initkwargs<\/code>, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440.<\/p>\n<pre><code class=\"python\">self = cls(**initkwargs)<\/code><\/pre>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0441\u043c\u0443\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>self<\/code>, \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0451 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0447\u0442\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u043c\u044b \u043d\u0435\u044f\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>__init__<\/code>,<\/p>\n<pre><code class=\"python\">def __init__(self, **kwargs):     \"\"\"     Constructor. Called in the URLconf; can contain helpful extra     keyword arguments, and other things.     \"\"\"     # Go through keyword arguments, and either save their values to our     # instance, or raise an error.     for key, value in kwargs.items():         setattr(self, key, value)<\/code><\/pre>\n<p>\u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u0440\u043e\u0445\u043e\u0434\u044f \u043f\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044e <code>**kwargs<\/code> (\u043d\u043e \u043c\u044b-\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043d <code>**initkwargs <\/code>:), \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>self<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>AboutView<\/code>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>setup<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 <code>view<\/code> (\u0442\u0435, \u0447\u0442\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u043b\u0438 \u0438\u0437 URL), \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430:<\/p>\n<pre><code class=\"python\">def setup(self, request, *args, **kwargs):     \"\"\"Initialize attributes shared by all view methods.\"\"\"     if hasattr(self, 'get') and not hasattr(self, 'head'):         self.head = self.get     self.request = request     self.args = args     self.kwargs = kwargs<\/code><\/pre>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043b\u0438 \u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 GET \u0438 HEAD: \u0435\u0441\u043b\u0438 <code>self.get<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0430 <code>self.head<\/code> \u043d\u0435\u0442, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>self.head<\/code> \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 <code>self.get<\/code>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435&nbsp;\u0432\u044b\u0437\u043e\u0432\u0430 <code>setup()<\/code>&nbsp;\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438&nbsp;<code>view()<\/code>&nbsp;\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f&nbsp;\u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430,&nbsp;\u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443&nbsp;<code>self<\/code>&nbsp;\u0435\u0441\u0442\u044c&nbsp;\u0430\u0442\u0440\u0438\u0431\u0443\u0442&nbsp;\u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"python\">if not hasattr(self, 'request'):     raise AttributeError(         \"%s instance has no 'request' attribute. Did you override \"         \"setup() and forget to call super()?\" % cls.__name__     )<\/code><\/pre>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0443\u0436\u043d\u0430: \u043c\u0435\u0442\u043e\u0434 <code>setup()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>request<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0431\u044b\u0442.<\/p>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 &#8212; <code>dispatch()<\/code>.<\/p>\n<pre><code class=\"python\">return self.dispatch(request, *args, **kwargs)<\/code><\/pre>\n<h2>3. dispatch()<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 dispatch() \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435: <\/p>\n<pre><code class=\"python\">def dispatch(self, request, *args, **kwargs):     # Try to dispatch to the right method; if a method doesn't exist,     # defer to the error handler. Also defer to the error handler if the     # request method isn't on the approved list.     if request.method.lower() in self.http_method_names:         handler = getattr(self, request.method.lower(), self.http_method_not_allowed)     else:         handler = self.http_method_not_allowed     return handler(request, *args, **kwargs)<\/code><\/pre>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0431\u0435\u0440\u0451\u043c HTTP-\u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (<code>request.method<\/code>), \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0430 \u043c\u0435\u0442\u043e\u0434 \u043b\u0438 \u043e\u043d, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0441 \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 <code>http_method_names<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>http_method_names<\/code> (\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>else<\/code>) \u0438\u043b\u0438 \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0438 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u0445 (\u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>getattr<\/code>), \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>http_method_not_allowed<\/code> , \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 View:<\/p>\n<pre><code class=\"python\">def http_method_not_allowed(self, request, *args, **kwargs):     logger.warning(         'Method Not Allowed (%s): %s', request.method, request.path,         extra={'status_code': 405, 'request': request}     )     return HttpResponseNotAllowed(self._allowed_methods())<\/code><\/pre>\n<p><code>http_method_not_allowed<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>HttpResponseNotAllowed<\/code> \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u0433\u043b\u0430\u0433\u043e\u043b \u043d\u0430\u0448\u0451\u043b\u0441\u044f, \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>handler<\/code> (\u0434\u043b\u044f OPTIONS \u2192 <code>options,<\/code>\u0434\u043b\u044f GET \u2192 <code>get<\/code>, \u0434\u043b\u044f POST \u2192 <code>post<\/code>).<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0440\u0430\u0431\u043e\u0442\u044b <code>dispatch()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <code>handler()<\/code>, \u0447\u0442\u043e, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e, \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u043b\u0438\u0431\u043e HttpResponse \u0441 \u043a\u043e\u0434\u043e\u043c 405, \u043b\u0438\u0431\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code>, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e  \u0432 \u043d\u0451\u043c \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <code>options()<\/code>.<\/p>\n<pre><code class=\"python\">    def options(self, request, *args, **kwargs):         \"\"\"Handle responding to requests for the OPTIONS HTTP verb.\"\"\"         response = HttpResponse()         response.headers['Allow'] = ', '.join(self._allowed_methods())         response.headers['Content-Length'] = '0'         return response<\/code><\/pre>\n<p>\u041e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c <code>Allow<\/code> \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438.<\/p>\n<p>\u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 GET?<\/p>\n<h2>4. get()<\/h2>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code> \u0432\u0441\u0451 \ud83d\ude42 \u0438 \u0432 \u0438\u0433\u0440\u0443 \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a <code>TemplateView<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d:<\/p>\n<pre><code class=\"python\">class TemplateView(TemplateResponseMixin, ContextMixin, View):     \"\"\"     Render a template. Pass keyword arguments from the URLconf to the context.     \"\"\"     def get(self, request, *args, **kwargs):         context = self.get_context_data(**kwargs)         return self.render_to_response(context)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u044f \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0443\u0436\u0435 \u043d\u0430\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043a\u043b\u0430\u0441\u0441 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 <code>get_context_data<\/code> \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0441\u0438 <code>ContextMixin<\/code>. <\/p>\n<pre><code class=\"python\">class ContextMixin:     \"\"\"     A default context mixin that passes the keyword arguments received by     get_context_data() as the template context.     \"\"\"     extra_context = None      def get_context_data(self, **kwargs):         kwargs.setdefault('view', self)         if self.extra_context is not None:             kwargs.update(self.extra_context)         return kwargs<\/code><\/pre>\n<p>\u041c\u0438\u043a\u0441\u0438\u043d \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f rocket science, \u0430 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0431\u0435\u0440\u0451\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 URL \u0430\u0434\u0440\u0435\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0443\u0434\u0430 \u043a\u043b\u044e\u0447 <code>'view'<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 (\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430), \u0438 \u043f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0438\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c <code>extra_context<\/code>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0434\u0440\u0443\u0433 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0438.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, <code>TemplateView<\/code> \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0440\u0438\u043c\u0435\u0441\u0438 <code>TemplateResponseMixin<\/code> \u0438 \u0435\u0451 \u043c\u0435\u0442\u043e\u0434\u0430 <code>render_to_response<\/code>.<\/p>\n<h2>5. TemplateResponseMixin<\/h2>\n<pre><code class=\"python\">class TemplateResponseMixin:     \"\"\"A mixin that can be used to render a template.\"\"\"     template_name = None     template_engine = None     response_class = TemplateResponse     content_type = None      def render_to_response(self, context, **response_kwargs):         \"\"\"         Return a response, using the `response_class` for this view, with a         template rendered with the given context.          Pass response_kwargs to the constructor of the response class.         \"\"\"         response_kwargs.setdefault('content_type', self.content_type)         return self.response_class(             request=self.request,             template=self.get_template_names(),             context=context,             using=self.template_engine,             **response_kwargs         )<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 (\u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0442\u043e \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/ref\/class-based-views\/mixins-simple\/#templateresponsemixin\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u0432\u044b \u0437\u0430\u0431\u044b\u043b\u0438, \u0442\u043e, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044f\u0441\u044c \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>TemplateView,<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0438\u043c\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0430 <code>'about.html'<\/code>, \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430.<\/p>\n<p>\u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 CBV. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u043c\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u0430\u0439\u0442 <a href=\"https:\/\/ccbv.co.uk\/\" rel=\"noopener noreferrer nofollow\">Classy Class-Based Views<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430 StackOverflow, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u0443\u0433\u043b\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0438\u043a\u0441\u0438\u043d\u0435 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 <code>TemplateResponse<\/code> (\u0435\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0438), \u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>get_template_names<\/code> :<\/p>\n<pre><code class=\"python\">def get_template_names(self):     \"\"\"     Return a list of template names to be used for the request. Must return     a list. May not be called if render_to_response() is overridden.     \"\"\"     if self.template_name is None:         raise ImproperlyConfigured(             \"TemplateResponseMixin requires either a definition of \"             \"'template_name' or an implementation of 'get_template_names()'\")     else:         return [self.template_name]<\/code><\/pre>\n<p>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u0432\u043e\u0437\u0431\u0443\u0436\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e.<\/p>\n<p>\u0418, \u043a\u0430\u043a \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>TemplateResponse<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 <code>get()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432 <code>dispatch()<\/code> \u0438 <code>view()<\/code>, \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 CBV \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0438\u043c\u0438 \u0432\u043b\u0430\u0434\u0435\u0435\u0442\u0435, \u0432\u043f\u0435\u0440\u0435\u0434\u0438 \u0432\u0430\u0441 \u0436\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/ref\/class-based-views\/generic-display\/\" rel=\"noopener noreferrer nofollow\">Generic display views<\/a>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a DetailView \u0438 ListView \u0441 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u0451\u043d\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0410 \u043f\u043e\u043a\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u044f\u043c:<\/p>\n<ol>\n<li>\n<p>CBV \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u043e\u0432, \u043d\u043e \u0432\u043e \u0433\u043b\u0430\u0432\u0435 \u0441\u0442\u043e\u0438\u0442 \u043a\u043b\u0430\u0441\u0441 <code>View<\/code> \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>as_view()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>as_view()<\/code> \u0432 URLConf \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>view()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e Django \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 view() \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 dispach() \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 HTTP-\u0433\u043b\u0430\u0433\u043e\u043b \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 HttpResponse \u0441 \u043a\u043e\u0434\u043e\u043c 405<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>TemplateResponse<\/code>, \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ol>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/ccbv.co.uk\/\" rel=\"noopener noreferrer nofollow\"><u>Classy Class-Based Views<\/u><\/a> \u2014 \u0440\u0435\u0441\u0443\u0440\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e CBV \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/epydoc.pythondiary.com\/generic-views\/module-tree.html\" rel=\"noopener noreferrer nofollow\">Epydoc.pythondiary.com<\/a> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u041e\u0442\u043b\u0438\u0447\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 Classy Class<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/ref\/class-based-views\/base\/\" rel=\"noopener noreferrer nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Django. \u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a><\/p>\n<\/li>\n<\/ul>\n<p>P.S.: \u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u0435\u043d\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b <a href=\"https:\/\/djangodeconstructed.com\/2020\/01\/03\/mental-models-for-class-based-views\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442 \u0432 \u0431\u043b\u043e\u0433\u0435 Django Deconstructed<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/568198\/\"> https:\/\/habr.com\/ru\/post\/568198\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 Django, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u043c\u0430\u0433\u0438\u044e \u0447\u0451\u0440\u043d\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0443 \u043c\u0435\u043d\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0435 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435. \u041e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u044f\u0449\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430 \u0432\u0430\u0441, \u043d\u043e \u043d\u0435 \u0434\u0430\u044e\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u042f \u0445\u043e\u0447\u0443 \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0437\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u043a\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0438, Class-based views \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0443\u0433\u0430\u044e\u0449\u0438\u043c\u0438 \u0438 \u044f \u043f\u043e\u0434\u0441\u0442\u0435\u0433\u043d\u0443 \u0432\u0430\u0441 \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0434\u0443\u043c\u0430\u043b\u0438 \u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u043a\u0430\u043a \u043e \u043d\u0435\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438.<\/p>\n<hr>\n<h3>Background<\/h3>\n<p>\u042f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0443 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431 \u041e\u041e\u041f \u0432 Python \u0438 \u043e\u043f\u044b\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u043c\u0430\u043c\u0438: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/482464\/\" rel=\"noopener noreferrer nofollow\"><u>*args \u0438 **kwargs<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=wKyUZY4-Dxc\" rel=\"noopener noreferrer nofollow\"><u>\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f<\/u><\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/141411\/\" rel=\"noopener noreferrer nofollow\"><u>\u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/u><\/a><\/p>\n<\/li>\n<li>\n<p>@classmethod<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/62203\/\" rel=\"noopener noreferrer nofollow\"><u>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 MRO<\/u><\/a>, \u043c\u0438\u043a\u0441\u0438\u043d\u044b<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=61UuKJRl2m0\" rel=\"noopener noreferrer nofollow\"><u>\u0424\u0443\u043d\u043a\u0446\u0438\u044f super()<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u044f \u0432\u043e\u0437\u044c\u043c\u0443 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 <code>AboutView<\/code>, \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 <code>TemplateView<\/code>, \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0436\u0438\u0437\u043d\u044c \u043a\u043b\u0430\u0441\u0441\u0430: \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u0440\u0435\u0434\u043a\u0438, \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0432\u044b\u0437\u043e\u0432 \u0438\u0437 URLConf, \u043f\u0440\u0438\u043c\u0435\u0441\u0438 \u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<pre><code class=\"python\"> class AboutView(TemplateView):     template_name = \"about.html\"<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u044f \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043c\u044b\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e. \u0414\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f, \u0438 \u043e\u043a\u0438\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u043d\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c. <\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/div>\n<\/details>\n<h2>0. URL dispatcher<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Django \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/topics\/http\/urls\/#how-django-processes-a-request\" rel=\"noopener noreferrer nofollow\">\u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 URL<\/a>: \u043e\u043d \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 URL c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u0438, \u043d\u0430\u0445\u043e\u0434\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 HttpRequest \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b <code>urlpatterns<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e Function-based&nbsp;View&nbsp;(FBV) \u0438 \u043d\u0430 Class-based&nbsp;View&nbsp;(CBV):<\/p>\n<pre><code class=\"python\">urlpatterns = [     # Function-based View     path('about\/', about),      # Class-based View     path('about\/', AboutView.as_view()), ]<\/code><\/pre>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043e\u0442\u043b\u0438\u0447\u0438\u0435: \u0432 <abbr title=\"Function-based&nbsp;View\">FBV<\/abbr> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>about<\/code>, \u0430 \u043d\u0435 <code>about()<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0451 (\u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440). \u0410 \u0432 <abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u2014 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 <code>.as_view()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c\u0438. \u041d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0438, \u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043a\u0430 \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 TemplateView<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">class TemplateView(TemplateResponseMixin, ContextMixin, View):     \"\"\"     Render a template. Pass keyword arguments from the URLconf to the context.     \"\"\"     def get(self, request, *args, **kwargs):         context = self.get_context_data(**kwargs)         return self.render_to_response(context)<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0436\u0435 \u043e\u043d \u0432\u0437\u044f\u043b\u0441\u044f? \u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u044e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f <code>AboutView<\/code>.<\/p>\n<h2>1. Class View<\/h2>\n<p><abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u043e\u0432, \u043d\u043e \u0432\u0441\u0435 <abbr title=\"Class-based&nbsp;View&nbsp;\">CBV<\/abbr> \u0431\u0435\u0440\u0443\u0442 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code>. \u041d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><figcaption>\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 AboutView<\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434&nbsp;View:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 View<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">class View:     \"\"\"     Intentionally simple parent class for all views. Only implements     dispatch-by-method and simple sanity checking.     \"\"\"      http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']      def __init__(self, **kwargs):         \"\"\"         Constructor. Called in the URLconf; can contain helpful extra         keyword arguments, and other things.         \"\"\"         # Go through keyword arguments, and either save their values to our         # instance, or raise an error.         for key, value in kwargs.items():             setattr(self, key, value)      @classonlymethod     def as_view(cls, **initkwargs):         \"\"\"Main entry point for a request-response process.\"\"\"         for key in initkwargs:             if key in cls.http_method_names:                 raise TypeError(                     'The method name %s is not accepted as a keyword argument '                     'to %s().' % (key, cls.__name__)                 )             if not hasattr(cls, key):                 raise TypeError(\"%s() received an invalid keyword %r. as_view \"                                 \"only accepts arguments that are already \"                                 \"attributes of the class.\" % (cls.__name__, key))          def view(request, *args, **kwargs):             self = cls(**initkwargs)             self.setup(request, *args, **kwargs)             if not hasattr(self, 'request'):                 raise AttributeError(                     \"%s instance has no 'request' attribute. Did you override \"                     \"setup() and forget to call super()?\" % cls.__name__                 )             return self.dispatch(request, *args, **kwargs)         view.view_class = cls         view.view_initkwargs = initkwargs          # take name and docstring from class         update_wrapper(view, cls, updated=())          # and possible attributes set by decorators         # like csrf_exempt from dispatch         update_wrapper(view, cls.dispatch, assigned=())         return view      def setup(self, request, *args, **kwargs):         \"\"\"Initialize attributes shared by all view methods.\"\"\"         if hasattr(self, 'get') and not hasattr(self, 'head'):             self.head = self.get         self.request = request         self.args = args         self.kwargs = kwargs      def dispatch(self, request, *args, **kwargs):         # Try to dispatch to the right method; if a method doesn't exist,         # defer to the error handler. Also defer to the error handler if the         # request method isn't on the approved list.         if request.method.lower() in self.http_method_names:             handler = getattr(self, request.method.lower(), self.http_method_not_allowed)         else:             handler = self.http_method_not_allowed         return handler(request, *args, **kwargs)      def http_method_not_allowed(self, request, *args, **kwargs):         logger.warning(             'Method Not Allowed (%s): %s', request.method, request.path,             extra={'status_code': 405, 'request': request}         )         return HttpResponseNotAllowed(self._allowed_methods())      def options(self, request, *args, **kwargs):         \"\"\"Handle responding to requests for the OPTIONS HTTP verb.\"\"\"         response = HttpResponse()         response.headers['Allow'] = ', '.join(self._allowed_methods())         response.headers['Content-Length'] = '0'         return response      def _allowed_methods(self):         return [m.upper() for m in self.http_method_names if hasattr(self, m)]<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0435, \u043d\u043e \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 Django.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 URLConf \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>as_view()<\/code>, \u043f\u0440\u0438\u043c\u0435\u043c \u0435\u0433\u043e \u0437\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043f\u043e\u0438\u0441\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 <abbr title=\"Method Resolution Order\">MRO<\/abbr> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>View<\/code>:<\/p>\n<pre><code class=\"python\">    @classonlymethod     def as_view(cls, **initkwargs):         \"\"\"Main entry point for a request-response process.\"\"\"         for key in initkwargs:             if key in cls.http_method_names:                 raise TypeError(                     'The method name %s is not accepted as a keyword argument '                     'to %s().' % (key, cls.__name__)                 )             if not hasattr(cls, key):                 raise TypeError(\"%s() received an invalid keyword %r. as_view \"                                 \"only accepts arguments that are already \"                                 \"attributes of the class.\" % (cls.__name__, key))          def view(request, *args, **kwargs):             # \u0437\u0434\u0435\u0441\u044c \u0431\u044b\u043b \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 view, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d                      view.view_class = cls         view.view_initkwargs = initkwargs          # take name and docstring from class         update_wrapper(view, cls, updated=())          # and possible attributes set by decorators         # like csrf_exempt from dispatch         update_wrapper(view, cls.dispatch, assigned=())         return view<\/code><\/pre>\n<p>\u0412 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f: \u0432\u043e\u2011\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>@classonlymethod<\/code> \u0438\u0437 <code>django.utils.decorators<\/code> \u2014 \u043f\u043e\u0442\u043e\u043c\u043e\u043a <code>builtins.classmethod<\/code>. \u0418\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432\u043e\u0437\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>AttributeError<\/code>.<\/p>\n<p>\u0412\u043e\u2011\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 <code>**kwargs<\/code> \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 <code>**initkwargs<\/code> \u2014 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435\u0441\u043f\u0440\u043e\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0438\u0436\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f view \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>**kwargs<\/code> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0415\u0441\u043b\u0438 \u0431\u044b \u0438\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 <code>**kwargs<\/code> \u0437\u0430\u0442\u0435\u043d\u0438\u043b \u0431\u044b \u0432\u043d\u0435\u0448\u043d\u0438\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f. \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u0438\u043c\u044f \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u043e\u043b\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 <code>**<\/code> \u2014 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0432\u0441\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c .<\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 <code>**initkwargs<\/code>? \u041f\u043e \u0437\u0430\u0434\u0443\u043c\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 Django, \u0432 <code>as_view<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <code>AboutView<\/code> \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<pre><code class=\"python\">path('about\/', TemplateView.as_view(template_name=\"about.html\"))<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>initkwargs = {'template_name': 'about.html'}<\/code>.<\/p>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 \u0434\u0430\u043b\u044c\u0448\u0435. \u0412 \u0446\u0438\u043a\u043b\u0435 for \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0438 <code>initkwargs<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0434\u0432\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"python\">for key in initkwargs:     if key in cls.http_method_names:         raise TypeError(             'The method name %s is not accepted as a keyword argument '             'to %s().' % (key, cls.__name__)         )<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 HTTP\u2011\u0433\u043b\u0430\u0433\u043e\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d\u0438 (\u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>http_method_names<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>View<\/code>)<\/p>\n<pre><code class=\"python\">http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']<\/code><\/pre>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/hr>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326591","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326591"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326591\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}