{"id":327196,"date":"2022-01-10T08:47:54","date_gmt":"2022-01-10T08:47:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=327196"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=327196","title":{"rendered":"<span>Django Rest Framework \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445: \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ModelSerializer<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/562050\/\">\u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>BaseSerializer<\/code> \u0438 <code>Serializer<\/code>, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0443-\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0443 <code>ModelSerializer<\/code>. <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"\/img\/image-loader.svg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/dn\/kf\/sf\/dnkfsf4d8gmnnxmf1qr2x6j_r6y.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u043e\u0432 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0438;<\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043f\u043e\u043b\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432;<\/li>\n<li>\u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>create<\/code> \u0438 <code>update<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043a\u0430\u043a \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Serializer<\/code>.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"modelserializer-neobhodimyy-minimum\">ModelSerializer: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0443\u0436\u0435\u043d <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/serializers.py#L1027\">\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441<\/a> <code>Meta<\/code> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1032\"><code>model<\/code><\/a> \u2014 \u044d\u0442\u043e \u0434\u0436\u0430\u043d\u0433\u043e-\u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440. \u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c <a href=\"https:\/\/djbook.ru\/rel3.0\/topics\/db\/models.html#abstract-base-classes\">\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439<\/a>.<\/li>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1101\">\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/a>:<br \/> \n<ul>\n<li><code>fields<\/code> \u2014 \u043f\u043e\u043b\u044f \u0434\u0436\u0430\u043d\u0433\u043e-\u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430;<\/li>\n<li><code>exclude<\/code> \u2014 \u043f\u043e\u043b\u044f \u0434\u0436\u0430\u043d\u0433\u043e-\u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"avtomaticheski-sozdavaemye-i-deklariruemye-polya\">\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f<\/h2>\n<p>  <\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f.<\/strong> \u041f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>Meta<\/code> \u044f\u0432\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>fields<\/code> \u0438\u043b\u0438 \u043d\u0435\u044f\u0432\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>exclude<\/code>, DRF \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0441 \u043e\u0434\u043d\u043e\u0438\u043c\u0451\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e\u0438\u043c\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442\u0441\u044f, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1313\"><code>build_unknown_field<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p><strong>\u0414\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f.<\/strong> \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Meta<\/code>, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/594141\/\">\u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class TownSerializer(serializers.ModelSerializer):    name = serializers.CharField(allow_blank=True)     class Meta:       model = Town       fields = ['id', 'writers', 'name']<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0435 <code>name<\/code> \u2014 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0435, \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f \u0438 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u043e\u043b\u044f <code>id<\/code> \u0438 <code>writers<\/code> \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>name<\/code> \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <code>fields<\/code>. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>fields<\/code>, \u0432 \u043d\u0451\u043c<a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1124\"> \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/a>, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u043f\u043e\u0434\u0431\u0435\u0440\u0451\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0410 \u0435\u0449\u0451 \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b <a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#readonlyfield\"><code>ReadOnlyField<\/code><\/a>, <a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#hiddenfield\"><code>HiddenField<\/code><\/a>, <a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#serializermethodfield\"><code>SerializerMethodField<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u043d\u043e \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043d\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>extra_kwargs<\/code> \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Meta<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"chto-oznachaet-fields--__all__\">\u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <code>fields = '__all__'<\/code><\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>fields<\/code> \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 <code>__all__<\/code>, \u0442\u043e \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u0445, \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>__all__<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1171\">\u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c<\/a> \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 <code>fields<\/code> \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"kak-pravilno-ispolzovat-fields-i-exclude\">\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>fields<\/code> \u0438 <code>exclude<\/code><\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 DRF \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>  <\/p>\n<ul>\n<li><code>fields<\/code> \u0438 <code>exclude<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1094\">\u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435<\/a>.<\/li>\n<li><code>exclude<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1088\">\u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c<\/a> \u043b\u0438\u0431\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c, \u043b\u0438\u0431\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u043e\u0434\u043d\u043e.<\/li>\n<li><code>fields<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0434\u0430\u043d \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043b\u0438\u0431\u043e <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1082\">\u043a\u043e\u0440\u0442\u0435\u0436\u0430<\/a> (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0435 \u043e\u0434\u043d\u043e) \u0438\u043b\u0438 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L77\">\u0441\u0442\u0440\u043e\u043a\u0438<\/a> <code>__all__<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0434\u043b\u044f \u0434\u0436\u0430\u043d\u0433\u043e-\u043c\u043e\u0434\u0435\u043b\u0438 <code>Writer<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class Writer(models.Model):     firstname = models.CharField(max_length=100...)     lastname = models.CharField(max_length=100...)     patronymic = models.CharField(max_length=100...)     birth_place = models.ForeignKey(to=Town...)     birth_date = models.DateField(...)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class WriterModelSerializer(serializers.ModelSerializer):      class Meta:         model = Writer         fields = '__all__'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044f <code>firstname<\/code> \u0438 <code>lastname<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class WriterModelSerializer(serializers.ModelSerializer):      class Meta:         model = Writer         fields = ['firstname', 'lastname']<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f, \u043a\u0440\u043e\u043c\u0435 <code>firstname<\/code> \u0438 <code>lastname<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class WriterModelSerializer(serializers.ModelSerializer):      class Meta:         model = Writer         exclude = ['firstname', 'lastname']<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"kak-drf-sozdayot-polya-dlya-modelnogo-serialayzera\">\u041a\u0430\u043a DRF \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/h2>\n<p>  <\/p>\n<p><strong>\u0421\u0431\u043e\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u0433\u0440\u0443\u043f\u043f\u0430\u043c.<\/strong> \u0421\u043d\u0430\u0447\u0430\u043b\u0430 DRF \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/utils\/model_meta.py#L29\"><code>get_field_info<\/code><\/a> \u0438\u0437 <code>rest_framework.utils.model_meta<\/code>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 <code>FieldResult<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/utils\/model_meta.py#L16\"><code>relations<\/code><\/a> \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <code>(\"forward_relations\")<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/djbook.ru\/rel3.0\/ref\/models\/relations.html#django.db.models.fields.related.RelatedManager\"><code>RelatedManager (\"reverse_relations\")<\/code><\/a>;<\/li>\n<li><code>fields_and_pk<\/code> \u2014 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 DRF \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/serializers.py#L1285\"><code>build_relational_field<\/code><\/a> \u2014 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0438\u0437 <code>relations<\/code>;<\/li>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/serializers.py#L1318\"><code>build_property_field<\/code><\/a> \u2014 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 property-\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438;<\/li>\n<li><a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1224\"><code>build_standard_field<\/code><\/a> \u2014 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0438\u0437 <code>fields_and_pk<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class Town(models.Model):     name = models.CharField(max_length=100, unique=True)  class Writer(models.Model):     firstname = models.CharField(max_length=100...)     lastname = models.CharField(max_length=100...)     patronymic = models.CharField(max_length=100...)     birth_place = models.ForeignKey(to=Town, to_field='name', related_name='writers'...)     birth_date = models.DateField(...)      def get_full_name(self):         return f'{self.firstname} {self.patronymic} {self.lastname}'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Town<\/code> DRF \u0432\u043e\u0437\u044c\u043c\u0451\u0442:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0435 <code>name<\/code> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0435\u0433\u043e \u0432 <code>fields_and_pk<\/code> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_standard_field<\/code>;<\/li>\n<li>\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 <code>writers<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c <code>Town<\/code> \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e <code>Writer<\/code>. <code>writers<\/code> \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <code>related_name<\/code> \u043f\u043e\u043b\u044f <code>birth_place<\/code> \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0451\u043d \u0432 <code>relations<\/code> \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_relational_field<\/code> \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_nested_field<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0418\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Writer<\/code> DRF \u0432\u043e\u0437\u044c\u043c\u0451\u0442:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u044f <code>firstname<\/code>, <code>lastname<\/code>, <code>patronymic<\/code>, <code>birth_date<\/code> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0438\u0445 \u0432 <code>fields_and_pk<\/code> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_standard_field<\/code>;<\/li>\n<li>\u043f\u043e\u043b\u0435 <code>birth_place<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u0432 <code>relations<\/code> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_relational_field<\/code> \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>build_nested_field<\/code>;<\/li>\n<li>\u043c\u0435\u0442\u043e\u0434 <code>get_full_name<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u0443 <code>build_property_field<\/code> \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 <code>hasattr(model_class, field_name)<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0434\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0434\u043b\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/strong> \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u043f\u043e\u043b\u044f\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439. \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>ModelSerializer<\/code> \u0435\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 DRF \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u042d\u0442\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/master\/rest_framework\/serializers.py#L878\"><code>serializer_fields_mapping<\/code><\/a>. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u2116<\/th>\n<th>\u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/th>\n<th>\u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#booleanfield\">BooleanField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#booleanfield\">BooleanField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#nullbooleanfield\">NullBooleanField<\/a><\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#charfield\">CharField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#charfield\">CharField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#textfield\">TextField<\/a><\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#datefield\">DateField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#datefield\">DateField<\/a><\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#datetimefield\">DateTimeField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#datetimefield\">DateTimeField<\/a><\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#decimalfield\">DecimalField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#decimalfield\">DecimalField <\/a><\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/fields\/#durationfield\">DurationField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#durationfield\">DurationField<\/a><\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#emailfield\">EmailField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#emailfield\">EmailField<\/a><\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#filefield\">FileField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#filefield\">FileField<\/a><\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#filepathfield\">FilePathField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#filepathfield\">FilePathField<\/a><\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#floatfield\">FloatField<\/a><\/td>\n<td><a href=\"https:\/\/djbook.ru\/rel3.0\/ref\/models\/fields.html#floatfield\">FloatField<\/a><\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#imagefield\">ImageField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#imagefield\">ImageField<\/a><\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#ipaddressfield\">IPAddressField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#genericipaddressfield\">GenericIPAddressField<\/a><\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#integerfield\">IntegerField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#autofield\">AutoField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#bigintegerfield\">BigIntegerField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#integerfield\">IntegerField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#positiveintegerfield\">PositiveIntegerField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#positivesmallintegerfield\">PositiveSmallIntegerField<\/a>, <a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#smallintegerfield\">SmallIntegerField<\/a><\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#slugfield\">SlugField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#slugfield\">SlugField<\/a><\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#timefield\">TimeField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#timefield\">TimeField<\/a><\/td>\n<\/tr>\n<tr>\n<td>16<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#urlfield\">URLField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#urlfield\">URLField<\/a><\/td>\n<\/tr>\n<tr>\n<td>17<\/td>\n<td><a href=\"https:\/\/ilyachch.gitbook.io\/django-rest-framework-russian-documentation\/overview\/navigaciya-po-api\/fields#uuidfield\">UUIDField<\/a><\/td>\n<td><a href=\"https:\/\/www.djbook.ru\/rel3.0\/ref\/models\/fields.html#uuidfield\">UUIDField<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u043d\u0435 <code>serializer_fields_mapping<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L906\">\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430<\/a> \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 <code>JSONField<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 <a href=\"https:\/\/djbook.ru\/rel3.0\/ref\/contrib\/postgres\/fields.html#postgresql-specific-model-fields\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439<\/a> \u0434\u043b\u044f PostgreSQL.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0434\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439.<\/strong> \u0414\u043b\u044f ForeignKey-\u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1285\">\u043f\u043e\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a>:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/relations\/#slugrelatedfield\"><code>SlugRelatedField<\/code><\/a>, \u0435\u0441\u043b\u0438 \u0432 \u043f\u043e\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <a href=\"https:\/\/djbook.ru\/rel3.0\/ref\/models\/fields.html?highlight=to_field#django.db.models.ForeignKey.to_field\"><code>to_field<\/code><\/a>;<\/li>\n<li><a href=\"https:\/\/www.django-rest-framework.org\/api-guide\/relations\/#primarykeyrelatedfield\"><code>PrimaryKeyRelatedField<\/code><\/a> \u0432\u043e \u0432\u0441\u0435\u0445 \u0438\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0435\u0439 ManyToMany \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439 (\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>RelatedManager<\/code>) \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>PrimaryKeyRelatedField<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>fields<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>Meta<\/code>. \u0421\u0442\u0440\u043e\u043a\u0430 <code>__all__<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1646\">\u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442<\/a> \u0432 \u0441\u0435\u0431\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 RelatedManager-\u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class Town(models.Model):     name = models.CharField(max_length=100, unique=True)  class Writer(models.Model):     # \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438     birth_place = models.ForeignKey(to=Town, to_field='name', related_name='writers',...)  class TownSerializer(serializers.ModelSerializer):    class Meta:       model = Town       fields = '__all__' # \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: `id` \u0438 `name` #\u0418\u041b\u0418  fields = ['id', 'name', 'writers'] \u2014 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043f\u043e\u043b\u0435 `writers`  # \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0437\u0430\u043f\u0438\u0441\u044f\u043c \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438  class WriterSerializer(serialziers.ModelSerializer):    class Meta:       model = Writer       fields = '__all__' # \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f `birth_place`,       # \u0442.\u043a. `forward_relations` \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 `__all__`.        # \u0434\u043b\u044f \u043f\u043e\u043b\u044f `birth_place` \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d \u043a\u043b\u0430\u0441\u0441 `SlugRelatedField`, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443       # \u0432 \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442 `to_field`.<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438.<\/strong> \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442: DRF <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/98e56e0327596db352b35fa3b3dc8355dc9bd030\/rest_framework\/serializers.py#L1295\">\u0441\u043e\u0437\u0434\u0430\u0451\u0442<\/a> <code>ReadOnlyField<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435. \u0411\u0435\u0437 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043e\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"rabota-s-vlozhennymi-obektami\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/h2>\n<p>  <\/p>\n<h3 id=\"atribut-depth\">\u0410\u0442\u0440\u0438\u0431\u0443\u0442 <code>depth<\/code><\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class TownSerializer(serializers.ModelSerializer):    class Meta:       model = Town       fields = ['id', 'name', 'writers']  s = TownSerializer(instance=Town.objects.first()) print(s.data) ------------- {'id': 1, 'name': '\u0412\u043e\u043b\u043e\u0433\u0434\u0430', 'writers': [6, 7]}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u043a\u043b\u044e\u0447\u0443 <code>writers<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u043e\u0432 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u0412\u043e\u043b\u043e\u0433\u0434\u0435.<br \/>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>depth<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>Meta<\/code>. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 <code>writers<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class TownSerializer(serializers.ModelSerializer):    class Meta:       model = Town       depth = 1       fields = ['id', 'name', 'writers']  s = TownSerializer(instance=Town.objects.first()) print(s.data) ------------- {    'id': 1,    'name': '\u0412\u043e\u043b\u043e\u0433\u0434\u0430',    'writers': [                   {'id': 6, 'firstname': '\u0412\u0430\u0440\u043b\u0430\u043c', 'lastname': '\u0428\u0430\u043b\u0430\u043c\u043e\u0432', ...},                   {'id': 7, 'firstname': '\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0438\u043d', 'lastname': '\u0411\u0430\u0442\u044e\u0448\u043a\u043e\u0432', ...}               ] }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>depth=1<\/code>, \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1214\"><code>build_nested_field<\/code><\/a>. \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u043b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 <code>RelatedManager<\/code>, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 <code>NestedSerializer<\/code>. <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1307\">\u0415\u0433\u043e \u043a\u043e\u0434<\/a> \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class NestedSerializer(ModelSerializer):    class Meta:        model = relation_info.related_model        depth = nested_depth - 1        fields = '__all__'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0438 \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2014 <code>fields = '__all__'<\/code>.<br \/>  \u0412\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u0412\u044b\u0445\u043e\u0434 \u2014 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u044b\u0435 \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<h3 id=\"serialayzer-v-kachestve-polya\">\u0421\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044f<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <code>depth<\/code> \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Meta<\/code>.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u0448\u0430\u0433\u0430.<\/p>\n<p>  <\/p>\n<p><strong>\u0428\u0430\u0433 \u043f\u0435\u0440\u0432\u044b\u0439.<\/strong> \u041f\u043e\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u044f\u0432\u043d\u043e \u0432 <code>declared fields<\/code> \u2014 \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430.<br \/>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>writers<\/code> \u0432 \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0432 <code>fields<\/code> \u0432 <code>Meta<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class TownSerializer(serializers.ModelSerializer):    # \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439    writers = \u2026     class Meta:        model = Town        fields = ['id', 'name', 'writers']<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0428\u0430\u0433 \u0432\u0442\u043e\u0440\u043e\u0439.<\/strong> \u041d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0435 <code>writers<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Writer<\/code>. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u044f, \u0444\u0430\u043c\u0438\u043b\u0438\u044e, \u043e\u0442\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0432\u0442\u043e\u0440\u0430 \u0438 \u0434\u0430\u0442\u0443 \u0435\u0433\u043e \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u043e\u043b\u044f <code>id<\/code> \u0438 <code>birth_place<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class WriterSerializer(serializers.ModelSerializer):     class Meta:        model = Writer        exclude = ('id', 'birth_place')<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0428\u0430\u0433 \u0442\u0440\u0435\u0442\u0438\u0439.<\/strong> \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044f \u0432 <code>TownSerializer<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class TownSerializer(serializers.ModelSerializer):    writers = WriterSerializer(many=True) # \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044f     class Meta:        model = Town        fields = ['id', 'name', 'writers']<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>many=True<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>writers<\/code> \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u043e\u0432 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0441\u043e \u0441\u0432\u044f\u0437\u044c\u044e \u00ab\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 <code>TownSerializer<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0438\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0411\u0414 \u0441\u043f\u0438\u0441\u043e\u043a <code>writers<\/code>, \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0435\u0433\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0443 <code>WriterSerializer<\/code>. \u041e\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0439 \u043d\u0430\u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"extra_kwargs-tonkaya-nastroyka-avtomaticheski-sozdavaemyh-poley\"><code>extra_kwargs<\/code>: \u0442\u043e\u043d\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439<\/h2>\n<p>  <\/p>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442 <code>extra_kwargs<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>Meta<\/code>. \u042d\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u043f\u043e\u043b\u044f \u0438\u0437 <code>fields<\/code> \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432 <code>exclude<\/code>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441\u043b\u0443\u0436\u0438\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 <code>Town<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u0438\u0437 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>name<\/code> \u043d\u0435 \u0432 \u0432\u0438\u0434\u0435 <code>{'name': '\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0433\u043e\u0440\u043e\u0434\u0430'}<\/code>, \u0430 \u0432 \u0432\u0438\u0434\u0435 <code>{'town': '\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0433\u043e\u0440\u043e\u0434\u0430'}<\/code>;<\/li>\n<li>\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>name<\/code> \u0432 \u0432\u0438\u0434\u0435 <code>{'name': '\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435_\u0433\u043e\u0440\u043e\u0434\u0430'}<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043f\u043e\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043b\u0438 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u2014 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432 \u043a\u0430\u043a\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u043e\u0440\u0443\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/561696\/\">\u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/594141\/\">\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c<\/a>, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0439\u0442\u0438 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">class Town(models.Model):     name = models.CharField(max_length=100, unique=True)  class TownModelSerializer(serializers.ModelSerializer):      class Meta:         model = Town         fields = ['town', 'name']         extra_kwargs = {             'town': {'source': 'name', 'read_only': True},             'name': {'write_only': True}         }<\/code><\/pre>\n<p>  <\/p>\n<p><code>TownModelSerializer(instance=Town.objects.first()).data<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 <code>{'town': '\u0412\u043e\u043b\u043e\u0433\u0434\u0430'}<\/code>.<\/p>\n<p>  <\/p>\n<p><code>TownModelSerializer(data={'name': '\u0410\u043d\u0430\u043f\u0430'})<\/code> \u043f\u043e\u0441\u043b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0432 <code>validated_data<\/code> \u0441\u043b\u043e\u0432\u0430\u0440\u044c <code>{'name': '\u0410\u043d\u0430\u043f\u0430'}<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u0443\u044e \u0434\u043e\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0443\u043a\u0430\u0437\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0438\u043c\u0451\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u043b\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u0435 <code>name<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c. \u0412 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b, \u043a\u043b\u044e\u0447\u0430 <code>name<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442;<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0443 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>town<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438, \u0447\u0442\u043e \u043e\u043d\u043e:<br \/> \n<ul>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Town<\/code> \u0442\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u044e\u0447 <code>town<\/code>;<\/li>\n<li>\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c (source) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0431\u0443\u0434\u0435\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 (\u043f\u043e\u043b\u0435) <code>name<\/code> \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Town<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e <code>read_only_fields<\/code> <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1380\">\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c<\/a> \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 <code>Meta<\/code>, \u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043b\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0430.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0438\u0431\u043a\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0438 \u0447\u0442\u043e \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u0438\u0435 DRF \u0441\u0445\u0435\u043c\u043e\u0439 \u00ab\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 = \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438\u00bb. \u0421 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043f\u043e\u043b\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u043e\u043b\u0435\u0439 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0441\u043e\u0447\u0435\u0442\u0430\u0442\u044c, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u043e\u0432 \u0437\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0441\u043b\u0435\u0434\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/060a3b632f6f6ff2f84235d1be5da55020c40ff3\/rest_framework\/serializers.py#L1345\"><code>include_extra_kwargs<\/code><\/a>.<br \/>  \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b <code>required<\/code>, <code>default<\/code>, <code>allow_blank<\/code>, <code>min_length<\/code>, <code>max_length<\/code>, <code>min_value<\/code>, <code>max_value<\/code>, <code>validators<\/code>, <code>queryset<\/code>\u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>read_only=True<\/code>. DRF \u043e\u0431\u0440\u0435\u0436\u0435\u0442 \u044d\u0442\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e <code>read_only;<\/code><\/li>\n<li>\u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>required<\/code> \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>default<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u043b\u0438\u0431\u043e truthy-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. DRF \u0443\u0434\u0430\u043b\u0438\u0442 <code>required<\/code>, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 <code>default<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"osobennosti-validacii-v-modelserializer\">\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432 <code>ModelSerializer<\/code><\/h2>\n<p>  <\/p>\n<p><strong>\u041c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b <code>unique_together<\/code>, <code>unique_for_date<\/code>, <code>unique_for_month<\/code>, <code>unique_for_year<\/code>.<\/strong> \u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u0430\u043a\u0438\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 DRF \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u0442 \u0438\u0445 \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440. \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/encode\/django-rest-framework\/blob\/0d5250cffada2ac250e24407953d4862d04d3dae\/rest_framework\/serializers.py#L1510\"><code>get_validators<\/code><\/a>. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u044f.<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>Meta<\/code> \u0437\u0430\u0434\u0430\u043d \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>validators<\/code>.<br \/>  \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 <code>validators<\/code>: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440, \u043a \u043d\u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>validators<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442, \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0451\u043c \u0432\u0441\u0435 \u043c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438.<\/li>\n<li><code>unique_together<\/code> \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0436\u0430\u043d\u0433\u043e-\u043c\u043e\u0434\u0435\u043b\u044f\u0445. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441\u043e\u0432\u0435\u0442\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e <code>constraints<\/code> \u0438 \u043a\u043b\u0430\u0441\u0441 <code>UniqueConstraint<\/code>.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438, \u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e DRF \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442.<\/li>\n<\/ol>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u043b\u044f.<\/strong> \u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b, \u043a\u0430\u043a \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>validators<\/code>, \u0442\u0430\u043a \u0438 \u0438\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u044f\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>unique<\/code>, <code>max_value<\/code>, <code>min_value<\/code>, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430. \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>get_field_kwargs<\/code> \u0438\u0437 <code>restframework.utils.field_mapping<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u0430\u0436\u043d\u043e:<\/strong> \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u043c \u043f\u043e\u043b\u044f\u043c. \u0414\u043b\u044f \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432\u0441\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u044b \u0432 Django REST Framework. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u0440\u0435\u043f\u043a\u0438\u0439 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 API \u0432 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><strong>\u0412\u0441\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0435\u0440\u0438\u0438:<\/strong><br \/>  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: <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/561696\/\">\u0447\u0430\u0441\u0442\u044c 1<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/562050\/\">\u0447\u0430\u0441\u0442\u044c 2<\/a><br \/>  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 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/567564\/\">\u0447\u0430\u0441\u0442\u044c 1<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/594141\/\">\u0447\u0430\u0441\u0442\u044c 2<\/a><\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/598349\/\"> https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/598349\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/yandex_praktikum\/blog\/562050\/\">\u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>BaseSerializer<\/code> \u0438 <code>Serializer<\/code>, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0443-\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0443 <code>ModelSerializer<\/code>. <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"\/img\/image-loader.svg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/dn\/kf\/sf\/dnkfsf4d8gmnnxmf1qr2x6j_r6y.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u043e\u0432 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u043e\u0440\u0440\u0435\u0441\u043f\u043e\u043d\u0434\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0438;<\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043f\u043e\u043b\u044f\u0445 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043c\u0435\u0442\u0430\u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u043e\u0432;<\/li>\n<li>\u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>create<\/code> \u0438 <code>update<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0438\u0430\u043b\u0430\u0439\u0437\u0435\u0440\u0430 \u043a\u0430\u043a \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>Serializer<\/code>.<\/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-327196","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327196","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=327196"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327196\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}