{"id":310982,"date":"2020-10-05T15:00:29","date_gmt":"2020-10-05T15:00:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=310982"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-10-05T15:00:29","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=310982","title":{"rendered":"\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u0434\u0438\u043d \u043a \u043e\u0434\u043d\u043e\u043c\u0443: \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0432 Django"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/522106\/\"><b><i>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/cpet\/\">\u00abWeb-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python\u00bb<\/a>.<\/i><\/b><\/p>\n<hr>\n<p>   \u041f\u0444\u0444\u2026 \u0421\u043d\u043e\u0432\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sf\/0l\/kd\/sf0lkdmnlp7zj7tshd6cw6qrelq.png\"><\/p>\n<p>   \u0412 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb;<\/li>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb;<\/li>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb.<\/li>\n<\/ul>\n<p>   \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u0438\u0437 \u043d\u0438\u0445 \u2013 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb.<a name=\"habracut\"><\/a><\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u0432 Django \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c. \u041e\u043d\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0438 \u0442.\u0434. \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 Django. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\/\u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0430\u0439\u0442\u0443 \u0431\u043b\u043e\u0433\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441, \u0445\u043e\u0431\u0431\u0438, \u043d\u0438\u0448\u0443 \u0438 \u0442.\u0434. \u0410 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u0430\u044f \u0441 Django, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442 \u0435\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 Django \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb. \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044e \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0432 Django \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. <\/p>\n<p>  1. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 Django \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<br \/>  \u0412 \u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0433\u0434\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b <i><a href=\"http:\/\/forms.py\/\">forms.py<\/a><\/i>. \u0412 <i><a href=\"http:\/\/forms.py\/\">forms.py<\/a><\/i> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code class=\"python\">from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User<\/code><\/pre>\n<p>   \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <code>UserCreationForm<\/code>. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u0430-\u043a\u043b\u0430\u0441\u0441, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: <code>model<\/code> \u0438 <code>fields<\/code>. \u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>model<\/code> \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>fields<\/code> \u2013 \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b.<\/p>\n<pre><code class=\"python\">class createUserForm(UserCreationForm):     class meta:         model = User         fields = ['username', 'password1', 'password2']<\/code><\/pre>\n<p>   \u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0444\u043e\u0440\u043c\u0443 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0434\u043b\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n<p>  2. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 <i><a href=\"http:\/\/models.py\/\">models.py<\/a><\/i> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"python\">from django.contrib.auth.models import User<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e \u0441\u0432\u044f\u0437\u044c\u044e \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 Django.<\/p>\n<pre><code class=\"python\">class Profile(models.Model):     user = models.OneToOneField(User, on_delete=models.CASCADE, null=True,)     name = models.CharField(max_length=200, null=True)     email = models.CharField(max_length=200, null=True)     address = models.CharField(max_length=200, null=True)      def __str__(self):         return self.name<\/code><\/pre>\n<p>  3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u044f.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <i><a href=\"http:\/\/forms.py\/\">form.py<\/a><\/i> \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0438\u0437 <i><a href=\"http:\/\/models.py\/\">models.py<\/a><\/i>, \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u043e\u0444\u0438\u043b\u044f.<\/p>\n<pre><code class=\"python\">from django import forms from django.utils.translation import ugettext_lazy as _ from .models import Profile<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <code>forms.ModelForm<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u0430-\u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: <code>model<\/code> \u0438 <code>fields<\/code>. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>model<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f, \u0430 <code>fields<\/code> \u2013 \u043f\u043e\u043b\u044f \u0444\u043e\u0440\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b.<\/p>\n<pre><code class=\"python\">class profileForm(forms.ModelForm):     class Meta:         model = Profile         fields = ['name', 'email', 'address'] #The labels attribute is optional. It is used to define the labels of the form fields created            labels = {                 &quot;name&quot;: _(&quot;Name     &quot;),                 &quot;email&quot;: _(&quot;Email Address&quot;),                 &quot;address&quot;: _(&quot;Street Address&quot;),                 }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0444\u043e\u0440\u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 <i><a href=\"http:\/\/views.py\/\">views.py<\/a><\/i> \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b.<\/p>\n<p>  4. \u041f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 <i><a href=\"http:\/\/views.py\/\">views.py<\/a><\/i>.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 <a href=\"http:\/\/forms.py\/\">forms.py<\/a> \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448 <i><a href=\"http:\/\/views.py\/\">views.py<\/a><\/i>, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<pre><code class=\"python\">from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login, from django.contrib import messages from .models import Profile from .forms import createUserForm, profileForm<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e <i>registerPage<\/i>. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438 \u0432\u0435\u0440\u043d\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<pre><code class=\"python\">def registerPage(request):         context = {}     return render(request, 'app_name\/register.html', context)<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0444\u043e\u0440\u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0432\u044b\u0437\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 POST. \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<pre><code class=\"python\">def registerPage(request):     if request.method == 'POST':         form = createUserForm(request.POST)         profile_form = profileForm(request.POST)      context = {'form': form, 'profile_form': profile_form}     return render(request, 'app_name\/register.html', context)<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043e\u0431\u0435\u0438\u0445 \u0444\u043e\u0440\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0445 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435. <\/p>\n<pre><code class=\"python\">def registerPage(request):     if request.method == 'POST':         form = createUserForm(request.POST)         profile_form = profileForm(request.POST)          if form.is_valid() and profile_form.is_valid():             user = form.save()              #we don't save the profile_form here because we have to first get the value of profile_form, assign the user to the OneToOneField created in models before we now save the profile_form.               profile = profile_form.save(commit=False)             profile.user = user              profile.save()      context = {'form': form, 'profile_form': profile_form}     return render(request, 'app_name\/register.html', context)<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b, \u043c\u044b \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<pre><code class=\"python\">def registerPage(request):     if request.method == 'POST':         form = createUserForm(request.POST)         profile_form = profileForm(request.POST)          if form.is_valid() and profile_form.is_valid():             user = form.save()              #we don't save the profile_form here because we have to first get the value of profile_form, assign the user to the OneToOneField created in models before we now save the profile_form.               profile = profile_form.save(commit=False)             profile.user = user              profile.save()              messages.success(request,  'Your account has been successfully created')              return redirect('login')      context = {'form': form, 'profile_form': profile_form}     return render(request, 'app_name\/register.html', context)<\/code><\/pre>\n<p>  5. \u0420\u0435\u043d\u0434\u0435\u0440 \u0448\u0430\u0431\u043b\u043e\u043d\u0430<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b\u0435 <code>register.html<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0433 \u0444\u043e\u0440\u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 POST \u0438 <code>action<\/code> \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u0442\u0435\u0433 \u0444\u043e\u0440\u043c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c <code>csrf_token<\/code> \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 django, \u0430 \u0437\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u044b (\u0444\u043e\u0440\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u044f). \u0422\u0430\u043a\u0436\u0435 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e \u043a\u043d\u043e\u043f\u043a\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<pre><code class=\"python\">&lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;                 {% csrf_token %}                     &lt;h3&gt;Register Profile&lt;\/h3&gt;                      &lt;div class=&quot;form-field&quot;&gt;                         {{profile_form.name.label_tag}}                         {{profile_form.name}}                     &lt;\/div&gt;                     &lt;div class=&quot;form-field&quot;&gt;                         {{form.username.errors}}                         {{form.username.label_tag}}                         {{form.username}}                     &lt;\/div&gt;                     &lt;div class=&quot;form-field&quot;&gt;                         {{profile_form.email.label_tag}}                         {{profile_form.email}}                     &lt;\/div&gt;                     &lt;div class=&quot;form-field&quot;&gt;                         {{profile_form.address.label_tag}}                         {{profile_form.address}}                     &lt;\/div&gt;                     &lt;div class=&quot;form-field&quot;&gt;                         {{form.password1.errors}}                         {{form.password1.label_tag}}                         {{form.password1}}                     &lt;\/div&gt;                     &lt;div class=&quot;form-field&quot;&gt;                         {{form.password2.errors}}                         {{form.password2.label_tag}}                         {{form.password2}}                     &lt;\/div&gt;                  &lt;hr&gt;                 &lt;input id=&quot;form-button&quot; class=&quot;btn btn-success btn-block&quot; type=&quot;submit&quot; value=&quot;Create Profile&quot;&gt;                 &lt;br&gt;                     {{form.non_field_errors}}                 &lt;p&gt;Already have an account? &lt;a href=&quot;{% url 'login' %}&quot;&gt;Login&lt;\/a&gt;&lt;\/p&gt;             &lt;\/form&gt;<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b, \u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u043d\u0438\u0437\u0443 \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0434\u043f\u0438\u0441\u044c\u044e <i>\u00abDon&#8217;t have an account? Register\u00bb<\/i>. <\/p>\n<pre><code class=\"plaintext\"> &lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;                    ...                  &lt;hr&gt;                 &lt;input id=&quot;form-button&quot; class=&quot;btn btn-success btn-block&quot; type=&quot;submit&quot; value=&quot;Login&quot;&gt;                                   {% for message in messages %}                 &lt;p&gt;{{message}}&lt;\/p&gt;                 {% endfor %}                 &lt;p&gt;Don't have an account? &lt;a href=&quot;{% url 'store:register' %}&quot;&gt;Register&lt;\/a&gt;&lt;\/p&gt;             &lt;\/form&gt;<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 \u0432\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb.<\/p>\n<p>  <a href=\"https:\/\/otus.pw\/cpet\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2a\/z8\/xk\/2az8xk2so48hq9b2ejyf3sjidzg.png\"><br \/>  <\/a><\/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\/company\/otus\/blog\/522106\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/522106\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/522106\/\"><b><i>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/cpet\/\">\u00abWeb-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python\u00bb<\/a>.<\/i><\/b><\/p>\n<hr>\n<p>   \u041f\u0444\u0444\u2026 \u0421\u043d\u043e\u0432\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445?<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sf\/0l\/kd\/sf0lkdmnlp7zj7tshd6cw6qrelq.png\"><\/p>\n<p>   \u0412 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb;<\/li>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb;<\/li>\n<li>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u00ab\u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb.<\/li>\n<\/ul>\n<p>   \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u0438\u0437 \u043d\u0438\u0445 \u2013 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u00ab\u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443\u00bb.<\/p>\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-310982","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310982","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=310982"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310982\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}