{"id":324706,"date":"2021-06-10T15:00:21","date_gmt":"2021-06-10T15:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=324706"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=324706","title":{"rendered":"Django Rest Framework \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445: \u0441\u043e\u0437\u0434\u0430\u0451\u043c API \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 (\u0447\u0430\u0441\u0442\u044c 1)"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0421\u0442\u0430\u0441 \u0413\u0430\u0440\u0430\u043d\u0436\u0430, \u044f \u0432\u044b\u043f\u0443\u0441\u043a\u043d\u0438\u043a \u043a\u0443\u0440\u0441\u0430 \u00ab<a href=\"https:\/\/praktikum.yandex.ru\/backend-developer\/?utm_source=pr&amp;utm_medium=content&amp;utm_content=10_06_21&amp;utm_campaign=pr_content_backend-developer_habr\">Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a>\u00bb \u0432 \u042f\u043d\u0434\u0435\u043a\u0441.\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0443\u043c\u0435. \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e Django Rest Framework (DRF) \u0438 \u0445\u043e\u0442\u044f\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u044d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a.<\/p>\n<p>  <\/p>\n<p>\u042f \u0433\u043e\u0442\u043e\u0432\u043b\u044e \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b DRF. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u044e\u043c\u0438\u043d\u043e\u043a \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u043e\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 DRF <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/tree\/master\/rest_framework\">\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c REST API \u043d\u0430 \u0431\u0430\u0437\u0435 Django Rest Framework, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0411\u0414). \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a drf \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 (\u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435). <\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dn\/kf\/sf\/dnkfsf4d8gmnnxmf1qr2x6j_r6y.png\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0423\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u0430\u043d\u044b \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\">\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0413\u0438\u0442\u0445\u0430\u0431\u0435<\/a>.<\/li>\n<li>\u0421\u0442\u0438\u043b\u044c \u0438 \u043e\u0431\u044a\u0451\u043c \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u043d\u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 DRF \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u0443\u0442\u044c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. <\/li>\n<li>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 Django \u0438 \u0437\u043d\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u044b \u041e\u041e\u041f \u043d\u0430 Python.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u043e\u0434\u0441\u043f\u043e\u0440\u044c\u0435\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f DRF \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u043f\u0440\u043e\u044f\u0441\u043d\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0430\u0441\u0442 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043b\u044e\u0431\u0430\u044f \u043c\u0430\u0433\u0438\u044f \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442, \u0441\u0442\u043e\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"api-dlya-sayta-na-django-obschaya-shema\">API \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u0430 \u043d\u0430 Django: \u043e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430<\/h2>\n<p>  <\/p>\n<h3 id=\"zadacha\">\u0417\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442 \u043d\u0430 Django. \u041d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u0430\u0439\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:8000<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0432\u0438\u0434\u044f\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0441\u0435\u0432\u0435\u0440\u043e\u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0438\u0445 \u0441\u0442\u043e\u043b\u0438\u0446\u0430\u0445. \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438\u0437 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u0439 \u043a \u0441\u0430\u0439\u0442\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c Capital \u0441 \u043f\u044f\u0442\u044c\u044e \u043f\u043e\u043b\u044f\u043c\u0438:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>id<\/th>\n<th>country<\/th>\n<th>capital_city<\/th>\n<th>capital_population<\/th>\n<th>author (FK)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>Norway<\/td>\n<td>Oslo<\/td>\n<td>693500<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>Sweden<\/td>\n<td>Stockholm<\/td>\n<td>961600<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Finland<\/td>\n<td>Helsinki<\/td>\n<td>655300<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>Iceland<\/td>\n<td>Reykjavik<\/td>\n<td>128800<\/td>\n<td>1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0435 <code>author<\/code> \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 (foreign key) \u0441\u0432\u044f\u0437\u0430\u043d\u043e <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/7904f82905a3d5c561a644a2aa1fc313baab9fcd\/capitals\/models.py#L6\">\u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e User<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c id.<\/p>\n<p>  <\/p>\n<p><strong>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044f \u0441\u0430\u0439\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0430 \u0441\u0434\u0435\u043b\u0430\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e Python-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0430\u0431\u043e\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438\u0437 Python-\u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439: \u043a\u043b\u044e\u0447 \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Capital, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f.<\/li>\n<li>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u2014 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0438\u0446, \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u044f \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0451\u0441 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u0430\u0437\u0443. \u0418\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 id \u0430\u0432\u0442\u043e\u0440\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u043e\u043b\u0435 <code>author<\/code>.<\/li>\n<li>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e \u0441\u0435\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Python-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f json-\u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{   'capital_city': 'Oslo',   'capital_population': 693500,   'author': 'test_user' }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 API \u2014 \u0434\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0438\u0437 \u0411\u0414 \u0441\u0430\u0439\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<h3 id=\"reshaem-zadachu-s-pomoschyu-django-rest-framework\">\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Django Rest Framework<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0432\u0430 \u0448\u0430\u0433\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u043b\u043e\u0436\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 Django-\u043c\u043e\u0434\u0435\u043b\u0438) \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/serializers#cerializatory\">\u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440<\/a>.<\/li>\n<li>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e \u0441\u0435\u0442\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 (\u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c) <a href=\"https:\/\/www.json.org\/json-ru.html\">\u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442<\/a> \u2014 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u043e\u0442 \u044f\u0437\u044b\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0440\u0435\u043d\u0434\u0435\u0440.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043e json. \u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 python \u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 json \u0438 <a href=\"https:\/\/docs.python.org\/3\/library\/json.html#json.JSONEncoder\">\u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f<\/a> \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>Python<\/th>\n<th>JSON<\/th>\n<th>\u041f\u0440\u0438\u043c\u0435\u0440 Python<\/th>\n<th>\u041f\u0440\u0438\u043c\u0435\u0440 JSON<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>dict<\/td>\n<td>object<\/td>\n<td>{&#8216;\u043a\u043b\u044e\u0447&#8217;: &#8216;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435&#8217;}<\/td>\n<td>{&quot;\u043a\u043b\u044e\u0447&quot;: &quot;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435&quot;}<\/td>\n<\/tr>\n<tr>\n<td>list, tuple<\/td>\n<td>array<\/td>\n<td>[&#8216;\u044d\u043b\u0435\u043c\u0435\u043d\u04421&#8217;, &#8216;\u044d\u043b\u0435\u043c\u0435\u043d\u04422&#8217;], (&#8216;\u044d\u043b\u0435\u043c\u0435\u043d\u04421&#8217;, &#8216;\u044d\u043b\u0435\u043c\u0435\u043d\u04422&#8217;)<\/td>\n<td>[&quot;\u044d\u043b\u0435\u043c\u0435\u043d\u04421&quot;, &quot;\u044d\u043b\u0435\u043c\u0435\u043d\u04422&quot;]<\/td>\n<\/tr>\n<tr>\n<td>str<\/td>\n<td>string<\/td>\n<td>&#8216;\u044d\u043b\u0435\u043c\u0435\u043d\u04421&#8217;<\/td>\n<td>&quot;\u044d\u043b\u0435\u043c\u0435\u043d\u04421&quot;<\/td>\n<\/tr>\n<tr>\n<td>int, float, int- &amp; float-derived Enums<\/td>\n<td>number<\/td>\n<td>5, 4.2<\/td>\n<td>5, 4.2<\/td>\n<\/tr>\n<tr>\n<td>True<\/td>\n<td>true<\/td>\n<td>True<\/td>\n<td>true<\/td>\n<\/tr>\n<tr>\n<td>False<\/td>\n<td>false<\/td>\n<td>False<\/td>\n<td>false<\/td>\n<\/tr>\n<tr>\n<td>None<\/td>\n<td>null<\/td>\n<td>None<\/td>\n<td>null<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<h3 id=\"sozdayom-serialayzer\">\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Capital \u2014 \u043e\u0431\u044a\u0435\u043a\u0442. \u0418 \u043a\u0430\u043a \u0443 \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0443 \u0437\u0430\u043f\u0438\u0441\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u0418\u0437\u0443\u0447\u0438\u043c \u0438\u0445 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0441\u0442\u043e\u043b\u0438\u0446\u0435 \u041d\u043e\u0440\u0432\u0435\u0433\u0438\u0438, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>__dict__<\/code>. \u041d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#object.__dict__\">\u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 (writable) \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">Capital.objects.first().__dict__  {     '_state': &lt;django.db.models.base.ModelState object at 0x00000126F2DB0BB0&gt;,     'id': 1,     'country': 'Norway',     'capital_city': 'Oslo',     'capital_population': 693500,      'author_id': 1 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Capital \u2014 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/e20e8e8dc418caea3e5264ccd52228995a1667b7\/capitals\/models.py#L10\"><code>\u043f\u043e\u043b\u0435 author<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#foreignkey\">\u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447<\/a> \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e User \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 id \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u043d\u0435\u0451, \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432 \u0411\u0414 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#database-representation\">\u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443<\/a> <code>_id<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043d\u0443\u0436\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 (\u043f\u043e\u043b\u0435\u0439) \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 python-\u0441\u043b\u043e\u0432\u0430\u0440\u044c \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>OrderedDict<\/code>. \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 Python \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.7 \u00ab\u043e\u0431\u044b\u0447\u043d\u044b\u0435\u00bb \u0441\u043b\u043e\u0432\u0430\u0440\u0438 <a href=\"https:\/\/docs.python.org\/3.7\/whatsnew\/3.7.html#summary-release-highlights\">\u0441\u0442\u0430\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c<\/a> \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043f\u0430\u0440 \u00ab\u043a\u043b\u044e\u0447 \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00bb.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u043b\u044f: \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/strong> \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Serializer<\/code>, \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u041d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0435\u0441\u0442\u044c <a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/serializers#modelserializer\"><code>\u043a\u043b\u0430\u0441\u0441 ModelSerializer<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0443\u0439\u0442\u0438 \u043e\u0442 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043d \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u0442\u0440\u0451\u0445 \u043f\u043e\u043b\u044f\u0445 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0435 <code>capital_city<\/code>,<\/li>\n<li>\u043f\u043e\u043b\u0435 <code>capital_population<\/code>,<\/li>\n<li>\u043f\u043e\u043b\u0435 <code>author<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442, \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u043e\u0436\u0435 \u0442\u0440\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430-\u043f\u043e\u043b\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044f \u0438 \u0435\u0433\u043e \u0442\u0438\u043f\u043e\u043c. \u041d\u0430\u0437\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e: \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0440\u0451\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8q\/py\/ix\/8qpyixotc6_titswyvknxevt4uo.png\"><\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u0442\u044b\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>a<\/code>, \u0442\u043e \u043a\u0430\u043a \u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 <code>capital_city<\/code>?<\/p>\n<p>  <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>source<\/code> \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u043e <code>a<\/code> \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043e <code>source='capital_city'<\/code>, \u0442\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 (\u043f\u043e\u043b\u044f) <code>capital_city<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430 <code>&quot;a&quot;: &quot;Oslo&quot;<\/code>.<\/li>\n<li>\u0427\u0435\u0440\u0435\u0437 \u0442\u043e\u0447\u0435\u0447\u043d\u0443\u044e \u043d\u043e\u0442\u0430\u0446\u0438\u044e \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0435 source \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u0437\u0430\u043f\u0438\u0441\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447. \u0422\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0438\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0443\u043a\u0430\u0437\u0430\u0432 <code>source='author.username'<\/code>.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 source \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d, \u0442\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442, \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f <a href=\"https:\/\/docs.python.org\/3\/library\/exceptions.html#AttributeError\"><code>\u043e\u0448\u0438\u0431\u043a\u0430 AttributeError<\/code><\/a>.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0435 <code>source<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 <a href=\"https:\/\/docs.python.org\/3\/library\/exceptions.html#AssertionError\"><code>\u043e\u0448\u0438\u0431\u043a\u0430 AssertionError<\/code><\/a>, a DRF \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0434\u0438\u0442: <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/71e6c30034a1dd35a39ca74f86c371713e762c79\/rest_framework\/fields.py#L375\">\u0442\u0430\u043a\u043e\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u0415\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>to_representation<\/code>. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0437\u0430\u0434\u0430\u0447\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043d\u043d\u044b\u0435 \u0438\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <code>serializers.IntegerField<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0435\u0433\u043e <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/fields.py#L962\"><code>\u043c\u0435\u0442\u043e\u0434 to_representation<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class IntegerField(Field):     . . .     def to_representation(self, value):         return int(value)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u043e\u043b\u0438\u0446\u044b: <code>int('\u041e\u0441\u043b\u043e')<\/code> \u0432\u044b\u0437\u043e\u0432\u0435\u0442 <a href=\"https:\/\/docs.python.org\/3\/library\/exceptions.html#ValueError\">ValueError<\/a>. \u0410 \u0432\u043e\u0442 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f \u2014 \u0441\u0430\u043c\u043e\u0435 \u0442\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 (\u043c\u043e\u0434\u0435\u043b\u0438)<\/th>\n<th>\u0422\u0438\u043f \u043f\u043e\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 (\u043c\u043e\u0434\u0435\u043b\u0438)<\/th>\n<th>\u0422\u0438\u043f \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>capital_city<\/td>\n<td>models.CharField<\/td>\n<td>serializers.CharField<\/td>\n<\/tr>\n<tr>\n<td>capital_population<\/td>\n<td>models.IntegerField<\/td>\n<td>serializers.IntegerField<\/td>\n<\/tr>\n<tr>\n<td>author<\/td>\n<td>models.CharField<\/td>\n<td>serializers.CharField<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u041e \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0438 \u043f\u043e\u043b\u0435\u0439 Django-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#logicheskie-polya\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 DRF<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u0442\u043e\u043c \u0436\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f Django-\u043c\u043e\u0434\u0435\u043b\u044c, \u043f\u043e\u0434 \u0438\u043c\u0435\u043d\u0435\u043c <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/capitals\/serializers.py\">serializers.py<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># capitals\/serializers.py from rest_framework import serializers  class CapitalSerializer(serializers.Serializer):     capital_city = serializers.CharField(max_length=200)     capital_population = serializers.IntegerField()     author = serializers.CharField(source='author.username', max_length=200)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u043e\u043b\u0435 <code>CharField<\/code> \u0443\u043a\u0430\u0437\u0430\u043d \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>max_length<\/code>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043f\u043e\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#charfield\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 <code>capital_city<\/code> \u0438 <code>capital_population<\/code> \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>source<\/code> \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0438 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442. \u0414\u043b\u044f \u043f\u043e\u043b\u044f <code>author<\/code>, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043d\u0443\u0436\u0435\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>source<\/code>. \u0412 \u043f\u043e\u043b\u0435 <code>author<\/code> \u043c\u043e\u0434\u0435\u043b\u0438 Capital \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e id \u0430\u0432\u0442\u043e\u0440\u0430, \u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0435\u0433\u043e username. \u0417\u0430 \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u044b \u0438\u0434\u0451\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u0435 <code>author<\/code> \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043a\u043b\u044e\u0447\u0443. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u0447\u0435\u0447\u043d\u0443\u044e \u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>author.username<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 <code>data<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u0442\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u0441\u043e\u0437\u0434\u0430\u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"serialayzer-v-deystvii\">\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438<\/h3>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0444\u0430\u0439\u043b\u0443 <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/serializer_example_1.py\"><code>serializer_example_1.py<\/code><\/a>. \u041e\u043d \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0430\u0439\u0442\u0443. \u041f\u043e\u0441\u043b\u0435 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0447\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (<a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/README.md\">\u0448\u0430\u0433\u0438 1\u20146 \u0438\u0437 \u0440\u0438\u0434\u043c\u0438<\/a>) \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Python-\u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412 <code>serializer_example_1.py<\/code> \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0430\u0445 \u0438 \u043e \u0441\u0442\u043e\u043b\u0438\u0446\u0430\u0445 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class User:     def __init__(self, username):         self.username = username  class Capital:     def __init__(self, country, capital_city, capital_population, user: User):         self.country = country         self.capital_city = capital_city         self.capital_population = capital_population         self.author = user<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">author_obj = User('test_user') capital_1 = Capital('Norway', 'Oslo', 693500, author_obj) . . . <\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044e \u043a\u0432\u0435\u0440\u0438\u0441\u0435\u0442\u0430 \u0438\u0437 Django-\u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">queryset = [capital_1, capital_2, capital_3, capital_4]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430: \u043a\u043e\u0434 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d \u0442\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0432\u044b\u0448\u0435 \u0434\u043b\u044f <code>class CapitalSerializer(serializers.Serializer)<\/code>. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">serializer_obj = CapitalSerializer(instance=queryset, many=True)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0443 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c. \u041e\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0435 <code>instance<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>many<\/code> \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>True<\/code>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0438 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0440\u0430\u0437\u043d\u0430\u044f. \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u044f <code>many=True<\/code>, \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0412 \u0447\u0451\u043c \u043e\u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f, \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># serializer_obj.data [     OrderedDict([('capital_city', 'Oslo'), ('capital_population', 693500),                  ('author', 'test_user')]),     OrderedDict([('capital_city', 'Stockholm'), ('capital_population', 961600),                   ('author', 'test_user')]),     ... ]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043a\u043b\u0430\u0441\u0441\u0430 <code>OrderedDict<\/code>. \u041e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 Python-\u043c\u043e\u0434\u0443\u043b\u0435 <code>collections<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/serializers.py#L16\">\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/a> <code>restframework.serializers<\/code>, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c: <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from collections import OrderedDict, defaultdict<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u043c <code>OrderedDict<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0442\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043e\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u043d\u044b \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u0414\u0430\u043d\u043d\u044b\u0445 \u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c \u043f\u043e\u043b\u044f <code>country<\/code> \u043d\u0435\u0442 \u2014 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"otobrazhaem-renderim-informaciyu-v-formate-json\">\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c (\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c) \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0440\u0435\u043d\u0434\u0435\u0440 \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/71e6c30034a1dd35a39ca74f86c371713e762c79\/rest_framework\/renderers.py#L53\"><code>JSONRenderer<\/code><\/a>. \u0412 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/serializer_example_2.py\"><code>serializer_example_2.py<\/code><\/a> \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u2014 \u043f\u043e\u043c\u0438\u043c\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u043e\u0432 \u0438\u0437 <code>restframework<\/code> \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u0440\u0435\u043d\u0434\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>render<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">json_render_for_our_data = renderers.JSONRenderer() data_in_json = json_render_for_our_data.render(serializer_obj.data)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0431\u0430\u0439\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c json-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">b'[{&quot;capital_city&quot;:&quot;Oslo&quot;,&quot;capital_population&quot;:693500,&quot;author&quot;:&quot;test_user&quot;},{&quot;capital_city&quot;:&quot;Stockholm&quot;,&quot;capital_population&quot;:961600,&quot;author&quot;:&quot;test_user&quot;},...]'<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0431\u0430\u0439\u0442\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0435\u0442\u0438 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 <code>content<\/code>, \u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0451 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 Python-\u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"chto-nuzhno-eschyo\">\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0451<\/h2>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u0441\u043f\u044b\u0442\u0430\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u044b\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0430\u0439\u0442 \u043d\u0430\u0447\u0430\u043b \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 (view) \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c url-\u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u2014 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442, \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0442\u043e\u043b\u0438\u0447\u043d\u044b\u0445 \u0433\u043e\u0440\u043e\u0434\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"kontroller\">\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/h3>\n<p>  <\/p>\n<p>\u0412\u043e <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/capitals\/views.py\"><code>views.py<\/code><\/a> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b DRF:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/3875d3284e73ed4d8e36c07d9b70c1b22c9d5998\/rest_framework\/views.py#L104\"><code>\u043a\u043b\u0430\u0441\u0441 APIView<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0436\u0438\u0442 \u043a\u0430\u0440\u043a\u0430\u0441\u043e\u043c \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430;<\/li>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/3875d3284e73ed4d8e36c07d9b70c1b22c9d5998\/rest_framework\/response.py#L14\"><code>\u043a\u043b\u0430\u0441\u0441 Response<\/code><\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u041f\u043e\u0445\u043e\u0436\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0435\u0441\u0442\u044c \u0432 \u00ab\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u00bb Django, \u0433\u0434\u0435 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 <code>HTTPRequest<\/code> <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/ref\/request-response\/#quick-overview\">\u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f<\/a> <code>HTTPResponse<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u2014 get. \u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a?<\/p>\n<p>  <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f <code>APIView<\/code>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0442\u0430\u043a\u043e\u0432\u0430: \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434, \u0447\u044c\u0451 \u0438\u043c\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/3875d3284e73ed4d8e36c07d9b70c1b22c9d5998\/rest_framework\/views.py#L500\">\u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0435\u0433\u043e http-\u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a> \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435. \u0420\u043e\u0432\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <a href=\"https:\/\/github.com\/django\/django\/blob\/main\/django\/views\/generic\/base.py#L97\">\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 View-\u043a\u043b\u0430\u0441\u0441 \u0432 Django<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b GET-\u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 get-\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>get<\/code> \u043e\u043f\u0438\u0448\u0435\u043c \u0442\u0443 \u0436\u0435 \u043b\u043e\u0433\u0438\u043a\u0443, \u0447\u0442\u043e \u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0441 \u043f\u0440\u043e\u0431\u043d\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0430 \u0438\u0445 \u043d\u0430\u0431\u043e\u0440 (<code>many=True<\/code>).<\/li>\n<li>\u041e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"python\"># capitals\/views.py from rest_framework.response import Response from rest_framework.views import APIView  from .models import Capital from .serializers import CapitalSerializer  class GetCapitalInfoView(APIView):     def get(self, request):         # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Capital         queryset = Capital.objects.all()         # \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439         serializer_for_queryset = CapitalSerializer(             instance=queryset, # \u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439             many=True # \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0451\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439         return Response(serializer_for_queryset.data)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0430\u0439\u043b\u0430 <code>serializer_example_2.py<\/code>, \u0433\u0434\u0435 \u043c\u044b \u044f\u0432\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438 json-\u0440\u0435\u043d\u0434\u0435\u0440 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>render<\/code>, \u0432 \u043a\u043e\u0434\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435\u0442. \u041d\u043e \u0440\u0435\u043d\u0434\u0435\u0440 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430-\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f <code>APIView<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043c\u0435\u0442\u043e\u0434 get, \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041e\u0431\u044a\u0435\u043a\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0443\u043b \u043c\u0435\u0442\u043e\u0434 get (<code>return Response({'capitals': serializer_for_queryset.data}<\/code>), \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/71e6c30034a1dd35a39ca74f86c371713e762c79\/rest_framework\/views.py#L418\"><code>finalize_response<\/code><\/a> \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>APIView<\/code>.<\/li>\n<li>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>finalize_response<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b:<br \/> \n<ul>\n<li><code>accepted_renderer<\/code> \u2014 \u0438\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 JSONRenderer,<\/li>\n<li><code>accepted_media_type<\/code> \u2014 &#8216;application\/json&#8217;,<\/li>\n<li><code>context<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/71e6c30034a1dd35a39ca74f86c371713e762c79\/rest_framework\/response.py#L50\"><code>rendered_content<\/code><\/a>: \u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 JSONRenderer \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>render<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0430\u0439\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/71e6c30034a1dd35a39ca74f86c371713e762c79\/rest_framework\/renderers.py#L85\">\u0432 json-\u0444\u043e\u0440\u043c\u0430\u0442<\/a>. \u041e\u043d\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 <code>content<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"marshrut-endpoint\">\u041c\u0430\u0440\u0448\u0440\u0443\u0442 (\u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442)<\/h3>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u0430 \u0436\u0435 \u0441\u0445\u0435\u043c\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u0430\u043a \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c Django. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f capitals:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># config\/urls.py from django.urls import include, path  urlpatterns = [     path('', include('capitals.urls')), ]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 <code>capitals<\/code> \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># capitals\/urls.py from django.urls import path  from . import views  urlpatterns = [     path('api\/capitals\/', views.GetCapitalInfoView.as_view()), ]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"api-v-deystvii\">API \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 API, \u043c\u043e\u0436\u043d\u043e:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c Python-\u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 <code>http:\/\/localhost:8000\/api\/capitals\/<\/code> \u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0430\u0439\u0442 \u2014 <code>python manage.py runserver<\/code>.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 Python-\u0441\u043a\u0440\u0438\u043f\u0442.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043d: \u0432 \u043a\u043e\u0440\u043d\u0435 \u0443\u0447\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b <a href=\"https:\/\/github.com\/stasyao\/drf_guide_part_1\/blob\/master\/get_info_from_our_site.py\"><code>get_info_from_our_site.py<\/code><\/a>. \u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a <code>http:\/\/localhost:8000\/api\/capitals\/<\/code>, \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 json-\u043e\u0442\u0432\u0435\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0442\u043e\u043b\u0438\u0446\u0430\u0445 \u0438 \u0438\u0445 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0448\u0430\u0433\u0438 2 \u0438 3.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0448\u0442\u0430\u0442\u043d\u043e, \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b <code>capitals.txt<\/code> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">The population of Oslo is 693500, author - test_user The population of Stockholm is 961600, author - test_user The population of Helsinki is 655300, author - test_user The population of Reykjavik is 128800, author - test_user<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0438\u0432\u043d\u044b\u0439, \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435: \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438<br \/>  \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043d\u0435 \u043e\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0430 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0418 \u0434\u0430\u043b\u0435\u0435 \u2014 \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h2 id=\"browsable-api--udobnyy-instrument-dlya-testirovaniya-api-na-drf\">Browsable API \u2014 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f API \u043d\u0430 DRF<\/h2>\n<p>  <\/p>\n<p>Django Rest Framework \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043a\u0430\u043a\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c API \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443 (\u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443). \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0417\u0430 \u0442\u0430\u043a\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/renderers\/#browsableapirenderer\">BrowsableAPIRenderer<\/a>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kq\/1m\/nu\/kq1mnupq7tax-er6b67upa29yqw.png\"><\/p>\n<p>  <\/p>\n<hr>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c API \u043d\u0430 \u0431\u0430\u0437\u0435 DRF, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 Django-\u043c\u043e\u0434\u0435\u043b\u0438. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435.<br \/>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/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\/company\/yandex_praktikum\/blog\/561696\/\"> https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/561696\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0421\u0442\u0430\u0441 \u0413\u0430\u0440\u0430\u043d\u0436\u0430, \u044f \u0432\u044b\u043f\u0443\u0441\u043a\u043d\u0438\u043a \u043a\u0443\u0440\u0441\u0430 \u00ab<a href=\"https:\/\/praktikum.yandex.ru\/backend-developer\/?utm_source=pr&amp;utm_medium=content&amp;utm_content=10_06_21&amp;utm_campaign=pr_content_backend-developer_habr\">Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a>\u00bb \u0432 \u042f\u043d\u0434\u0435\u043a\u0441.\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0443\u043c\u0435. \u042f \u0445\u043e\u0447\u0443 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e Django Rest Framework (DRF) \u0438 \u0445\u043e\u0442\u044f\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u044d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a.<\/p>\n<p>  <\/p>\n<p>\u042f \u0433\u043e\u0442\u043e\u0432\u043b\u044e \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b DRF. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0438\u0437\u044e\u043c\u0438\u043d\u043e\u043a \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u043e\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 DRF <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/tree\/master\/rest_framework\">\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c REST API \u043d\u0430 \u0431\u0430\u0437\u0435 Django Rest Framework, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0411\u0414). \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a drf \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 (\u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435). <\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dn\/kf\/sf\/dnkfsf4d8gmnnxmf1qr2x6j_r6y.png\"><\/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-324706","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324706","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=324706"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324706\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}