{"id":302923,"date":"2020-05-02T21:00:28","date_gmt":"2020-05-02T21:00:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=302923"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=302923","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/500142\/\">\n<p>\u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a> \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c, \u0430 \u0442\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0438\u043f\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u0420\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u2014 \u0433\u0434\u0435-\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0430 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u2014 \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u0435\u0433\u043e \u0443\u0441\u043b\u0443\u0433. \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u2014 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a>. \u0412\u0441\u0435, \u043a\u043e\u043c\u0443 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"primer\">\u041f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0435. \u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0445. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u2014 \u043c\u043e\u0436\u0435\u0442 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0431 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0430 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/li>\n<li>\u041f\u0435\u0440\u0441\u043e\u043d\u0430\u043b \u2014 \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u2014 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0440\u043e\u043c\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0430 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443<\/li>\n<li>\u0410\u0443\u0434\u0438\u0442\u043e\u0440 \u2014 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445<\/li>\n<li>\u041a\u043b\u0438\u0435\u043d\u0442 \u2014 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043b\u0438\u0447\u043d\u043e \u0441 \u043d\u0438\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"poryadok-vzaimodeystviya-s-sistemoy-prav-djangohttpsdocsdjangoprojectcomen\">\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043f\u0440\u0430\u0432 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a><\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>, \u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u0442\u0440\u043e\u043d\u0443\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u0430 <code>django.contrib.auth<\/code>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439 <code>Permission<\/code> \u0438 <code>Group<\/code> \u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e, \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0430\u043c\u0438, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"nachalo\">\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432 \u043d\u0435\u043c \u2014 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>django-admin startproject sample<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u041c\u043d\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u044e \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>sample<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <code>sample<\/code> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>options<\/code> \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u0441\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u044d\u0442\u043e \u0438\u043c\u044f.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0436\u0430\u043d\u0433\u043e-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>trans<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>python manage.py startapp trans<\/code> \u0438 \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"struktura-dannyh-proekta\">\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Project<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">class Project(models.Model):     name = models.CharField(         max_length=256,         db_index=True,         verbose_name=_('Name'),         help_text=_('Name of the project')     )     def __str__(self):         return self.name     class Meta:         verbose_name = _('Project')         verbose_name_plural = _('Projects')<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c. \u041c\u044b \u043e\u0442\u0440\u0430\u0437\u0438\u043c \u044d\u0442\u043e \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <code>ProjectMember<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">class ProjectMember(models.Model):     user = models.ForeignKey(         settings.AUTH_USER_MODEL, on_delete=models.CASCADE,         verbose_name=_('User'), help_text=_('User who belongs to this project'),         related_name='projects',     )     project = models.ForeignKey(         Project, on_delete=models.CASCADE,         verbose_name=_('Project'), help_text=_('Project to which this user belongs'),         related_name='users',     )     allow_change = models.BooleanField(         default=True,         verbose_name=_('Allow Change'),         help_text=_('Is the member allowed to change the project data?')     )     allow_manage = models.BooleanField(         default=False,         verbose_name=_('Allow Manage'),         help_text=_('Is the member allowed to manage users for the project?')     )      def __str__(self):         return _('%s -&gt; %s') % (self.user, self.project)      class Meta:         verbose_name = _('Project Member')         verbose_name_plural = _('Project Members')         unique_together = (             ('user', 'project'),         )<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u043c \u0443\u0441\u043b\u0443\u0433 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0443\u0441\u043b\u0443\u0433 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044f \u0444\u0430\u043a\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0441\u043b\u0443\u0433 \u043f\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u0430\u043a\u043e\u0435-\u043b\u0438\u0431\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u043f\u043e\u043c\u0438\u043c\u043e \u0444\u0430\u043a\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u0443\u0433 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0410\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438 <code>Vehicle<\/code><\/li>\n<li>\u0412\u043e\u0434\u0438\u0442\u0435\u043b\u0438 <code>Driver<\/code><\/li>\n<li>\u0417\u0430\u043a\u0430\u0437\u044b <code>Order<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u0438\u0437 \u043d\u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u044f\u0432\u043d\u043e\u0435 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0430 \u0437\u0430\u043a\u0430\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u0440\u043e\u0439 \u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c-\u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">class Vehicle(models.Model):     project = models.ForeignKey(         Project, on_delete=models.CASCADE,         verbose_name=_('Project'), help_text=_('Project to which this vehicle belongs'),         related_name='vehicles',     )     code = models.CharField(         max_length=256,         db_index=True,         verbose_name=_('Code'),         help_text=_('Registration code')     )     def __str__(self):         return self.code     class Meta:         verbose_name = _('Vehicle')         verbose_name_plural = _('Vehicles')         unique_together = (             ('code', 'project'),         )  class Driver(models.Model):     project = models.ForeignKey(         Project, on_delete=models.CASCADE,         verbose_name=_('Project'), help_text=_('Project to which this driver belongs'),         related_name='drivers',     )     user = models.ForeignKey(         settings.AUTH_USER_MODEL, on_delete=models.CASCADE,         verbose_name=_('User'), help_text=_('User who is a driver'),         related_name='driving',     )     def __str__(self):         return _('%s [%s]') % (self.user, self.project)      class Meta:         verbose_name = _('Driver')         verbose_name_plural = _('Drivers')         unique_together = (             ('user', 'project'),         )  class Order(models.Model):     project = models.ForeignKey(         Project, on_delete=models.CASCADE,         verbose_name=_('Project'), help_text=_('Project to which this order belongs'),         related_name='orders',     )     client = models.ForeignKey(         settings.AUTH_USER_MODEL, on_delete=models.CASCADE,         verbose_name=_('Client'), help_text=_('Client getting an order'),         related_name='orders',     )     vehicle = models.ForeignKey(         Vehicle, on_delete=models.CASCADE,         verbose_name=_('Vehicle'), help_text=_('Vehicle assigned to this order'),         related_name='orders',     )     driver = models.ForeignKey(         Driver, on_delete=models.CASCADE,         verbose_name=_('Driver'), help_text=_('Driver assigned to this order'),         related_name='orders',     )     start_time = models.DateTimeField(         db_index=True,         verbose_name=_(&quot;Start Time&quot;),         help_text=_(&quot;Time when the order is started&quot;)     )     stop_time = models.DateTimeField(         db_index=True,         verbose_name=_(&quot;Stop Time&quot;),         help_text=_(&quot;Time when the order is stopped&quot;)     )     def __str__(self):         return _('%(start_time)s-%(stop_time)s %(client)s %(driver)s %(vehicle)s') % {             'start_time': self.start_time,             'stop_time': self.stop_time,             'client': self.client,             'driver': self.driver,             'vehicle': self.vehicle,         }     class Meta:         verbose_name = _('Order')         verbose_name_plural = _('Orders')<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"sozdanie-adminok\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0434\u043c\u0438\u043d\u043e\u043a<\/h2>\n<p>  <\/p>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>access<\/code> \u0438 <code>trans<\/code> \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 settings.py, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>python makemigrations trans<\/code> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>python migrate<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 <code>admin.py<\/code> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <code>trans<\/code>. \u0412 \u0430\u0434\u043c\u0438\u043d\u043a\u0430\u0445 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0410 \u044d\u0442\u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c?<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0442\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u043c <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043f\u0440\u0430\u0432\u0430 \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u043f\u043e\u0434 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a>, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>, \u043e\u0442\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0430.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">@admin.register(Project) class ProjectAdmin(AccessModelAdmin):     fields = ['name']     list_display = ['name']     search_fields = ['name']  @admin.register(ProjectMember) class ProjectMemberAdmin(AccessModelAdmin):     fields = ['user', 'project', 'allow_manage', 'allow_change']     list_display = ['user', 'project', 'allow_manage', 'allow_change']     search_fields = ['user__username', 'user__first_name', 'user__last_name', 'project__name']     list_filters = ['project', 'allow_manage', 'allow_change']     autocomplete_fields = ['user', 'project']      def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = AccessManager(Project).changeable(request)             kwargs[&quot;queryset&quot;] = projects         return super(ProjectMemberAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)  @admin.register(Vehicle) class VehicleAdmin(AccessModelAdmin):     fields = ['project', 'code']     list_display = ['code', 'project']     list_filters = ['project']     search_fields = ['code']      def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = Project.objects.filter(users__user=request.user, users__allow_change=True)             kwargs[&quot;queryset&quot;] = projects         return super(VehicleAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)  @admin.register(Driver) class DriverAdmin(AccessModelAdmin):     fields = ['project', 'user']     list_display = ['user', 'project']     list_filters = ['project']     search_fields = ['user__username', 'user__first_name', 'user__last_name', 'project__name']     autocomplete_fields = ['user', 'project']      def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = Project.objects.filter(users__user=request.user, users__allow_change=True)             kwargs[&quot;queryset&quot;] = projects         return super(DriverAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)  @admin.register(Order) class OrderAdmin(AccessModelAdmin):     fields = ['project', 'client', 'vehicle', 'driver', 'start_time', 'stop_time']     list_display = ['start_time', 'stop_time', 'client', 'driver', 'vehicle', 'project']     list_filters = ['project', 'vehicle', 'driver']     search_fields = ['client__username', 'client__first_name', 'client__last_name', 'project__name',]     autocomplete_fields = ['client', 'vehicle', 'driver', 'project']     date_hierarchy = 'start_time'      def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = Project.objects.filter(users__user=request.user, users__allow_change=True)             kwargs[&quot;queryset&quot;] = projects         return super(OrderAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u0442\u0442\u0443\u0434\u0430 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u0433\u043e\u043d\u043a\u0443 \u043f\u0440\u0430\u0432.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u043d\u0438\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u0420\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043d\u0430\u0434 \u043a\u043e\u0434\u043e\u043c \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a \u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443, \u043a\u043e\u0433\u0434\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u044f\u0445 autocomplete:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">admin.site.unregister(User) admin.site.unregister(Group)  @admin.register(User) class AccessUserAdmin(AccessControlMixin, UserAdmin):     def get_readonly_fields(self, request, obj=None):         readonly_fields = super(AccessUserAdmin, self).get_readonly_fields(request, obj) or []         if request.user.is_superuser:             return readonly_fields         if not obj:             return readonly_fields         restrict = ['is_superuser', 'last_login', 'date_joined']         if obj.pk != request.user.pk:             restrict = ['is_superuser', 'last_login', 'date_joined', 'password', 'email']         return [f for f in readonly_fields if f not in restrict] + restrict      def get_list_display(self, request):         fields = super(AccessUserAdmin, self).get_list_display(request) or []         if request.user.is_superuser:             return fields         restrict = ['password', 'email']         return [f for f in fields if not f in restrict]      def _fieldsets_exclude(self, fieldsets, exclude):         ret = []         for nm, params in fieldsets:             if 'fields' not in params:                 ret.append((nm, params))                 continue             fields = []             for f in params['fields']:                 if f not in exclude:                     fields.append(f)             pars = {}             pars.update(params)             pars['fields'] = fields             ret.append((nm, pars))         return ret      def _fieldsets_only(self, fieldsets, only):         ret = []         for nm, params in fieldsets:             if 'fields' not in params:                 ret.append((nm, params))                 continue             fields = []             for f in params['fields']:                 if f in only:                     fields.append(f)             pars = {}             pars.update(params)             pars['fields'] = fields             ret.append((nm, pars))         return ret      def get_fieldsets(self, request, obj=None):         fieldsets = list(super(AccessUserAdmin, self).get_fieldsets(request, obj)) or []         fields = self.get_fields(request, obj=obj)         return self._fieldsets_only(fieldsets, fields)      def get_fields(self, request, obj=None):         fields = list(super(AccessUserAdmin, self).get_fields(request, obj)) or []         exclude = ['is_staff', 'groups', 'user_permissions']         if not request.user.is_superuser:             exclude = ['is_staff', 'is_superuser', 'groups', 'user_permissions']             if obj and obj.pk != request.user.pk:                 exclude = ['is_staff', 'password', 'email', 'groups', 'user_permissions']         return [f for f in fields if not f in exclude]      def save_model(self, request, obj, form, change):         obj.is_staff = True         return super(AccessUserAdmin, self).save_model(request, obj, form, change)<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0444\u043b\u0430\u0433\u043e\u043c <code>is_staff<\/code> \u0438 \u0441\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u043c \u0444\u043b\u0430\u0433\u043e\u043c <code>is_superuser<\/code>), \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0430\u0432 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"sozdanie-shemy-upravleniya-pravami\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0430\u043c\u0438<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <code>authorize<\/code>. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0430\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0436\u0435\u043c \u0432\u0441\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435?<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041c\u044b \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 authorize \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 <code>INSTALLED_APPS<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>settings.py<\/code>, \u0447\u0442\u043e\u0431\u044b \u043a \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432 \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">INSTALLED_APPS = [     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.messages',     'django.contrib.staticfiles',      'access',     'trans',      # SHOULD BE ALWAYS LAST!     'authorize', ]<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>python manage.py startapp authorize<\/code> \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u0430 <code>models.py<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u043d\u0435\u043c \u0432\u0441\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0417\u0430\u0447\u0435\u043c?<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u041c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043c \u0444\u0430\u043a\u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 <code>models.py<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435\u0441\u044f \u0432 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 <code>INSTALLED_APPS<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0432\u043e\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c (\u043a\u0440\u043e\u043c\u0435 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f) \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043b\u0438\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u0440\u043e\u043c\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435. \u0414\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0438\u043c\u0435\u044f \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u043e\u0437\u0433\u043e\u043d\u043a\u0443 \u043f\u0440\u0430\u0432 \u0434\u043e \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0438\u0445 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a\u0440\u043e\u043c\u0435 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u043c\u043e\u0433\u0443\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u0447\u0442\u043e \u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043d\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0443\u0432\u0438\u0434\u0438\u0442 \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0431\u044f.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c&#8230;<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u0430 \u043c\u043d\u0435 \u0442\u043e\u0436\u0435, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0430\u043c\u0438 \u043c\u043e\u0433\u043b\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u043c \u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0446\u0441\u0435\u0442\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0441\u044e\u0434\u0430 \u0441\u0430\u043c\u0438 \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">AccessManager.register_plugins({     User: CompoundPlugin(         CheckAblePlugin(             appendable=(lambda model, request:                  {} if request.user.id and request.user.projects.filter(allow_manage=True) else                 False             ),         ),         ApplyAblePlugin(             visible=(                 lambda queryset, request:                     queryset if request.user.projects.filter(                         allow_manage=True                     ) else queryset.filter(                         projects__project__users__user=request.user.id                     ).distinct() or queryset.filter(                         id=request.user.id                     ).distinct()             ),             changeable=(lambda queryset, request: queryset.filter(id=request.user.id).distinct()),             deleteable=(lambda queryset, request: queryset.filter(id=request.user.id).distinct())         )     ), })<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0435 \u0432 \u043d\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0447\u0442\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043a\u0440\u043e\u043c\u0435 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043d\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e. \u0422\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u043b\u0435\u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043c\u043e\u0433\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0430\u0432\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0432\u0438\u0434\u044f\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438 \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u0442, \u043d\u043e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">AccessManager.register_plugins({     Project: CompoundPlugin(         CheckAblePlugin(             appendable=(lambda model, request: False),         ),         ApplyAblePlugin(             visible=(lambda queryset, request: queryset.filter(                 users__user=request.user.id             ).distinct()),             changeable=(lambda queryset, request: queryset.filter(                 users__user=request.user.id,                 users__allow_manage=True             ).distinct()),             deleteable=(lambda queryset, request: queryset.none()),         )     ),     ProjectMember: CompoundPlugin(         CheckAblePlugin(             appendable=(lambda model, request: {} if request.user.id and request.user.projects.filter(allow_manage=True) else False),         ),         ApplyAblePlugin(             visible=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id             ).distinct()),             changeable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_manage=True             ).distinct()),             deleteable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_manage=True             ).distinct()),         )     ), })<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043f\u0440\u0430\u0432\u0430\u0445. \u0412\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u043e \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0444\u043b\u0430\u0433\u043e\u043c <code>allow_change<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043d\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u043c (\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c) \u0438\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Driver<\/code> \u2014 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c<\/li>\n<li><code>Order<\/code> \u2014 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0423\u0447\u0442\u0435\u043c \u044d\u0442\u043e \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">AccessManager.register_plugins({     Vehicle: CompoundPlugin(         ApplyAblePlugin(             visible=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id             ).distinct()),             changeable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),             deleteable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),         )     ),     Driver: CompoundPlugin(         ApplyAblePlugin(             visible=(lambda queryset, request: queryset.filter(                 Q(project__users__user=request.user.id) | Q(user=request.user)             ).distinct()),             changeable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),             deleteable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),         )     ),     Order: CompoundPlugin(         ApplyAblePlugin(             visible=(lambda queryset, request: queryset.filter(                 Q(                     project__users__user=request.user.id                 ) | Q(                     client=request.user                 ) | Q(                     driver__user=request.user                 )             ).distinct()),             changeable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),             deleteable=(lambda queryset, request: queryset.filter(                 project__users__user=request.user.id,                 project__users__allow_change=True             ).distinct()),         )     ), })<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432?<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u043d\u0435\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a> \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043e\u043b\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u0430\u043a-\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 \u0430\u0434\u043c\u0438\u043d\u043a\u0438, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u0435\u0437\u0434\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>project<\/code>, \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u0434\u043c\u0438\u043d\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>ProjectMember<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">    ...     def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = AccessManager(Project).changeable(request)             kwargs[&quot;queryset&quot;] = projects         return super(ProjectMemberAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">    ...     def formfield_for_foreignkey(self, db_field, request, **kwargs):         if db_field.name == &quot;project&quot;:             projects = Project.objects.filter(users__user=request.user, users__allow_change=True)             kwargs[&quot;queryset&quot;] = projects         return super(..., self).formfield_for_foreignkey(db_field, request, **kwargs)<\/code><\/pre>\n<p>  <\/p>\n<p>(\u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0442\u043e\u0447\u0438\u044f\u2026 \u043c\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0430\u0434\u043c\u0438\u043d\u043a\u0438).<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0434\u0435\u0442\u0430\u043b\u044c. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e \u0448\u0442\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043f\u0440\u0430\u0432 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>, \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u043e \u0432\u0441\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044f\u043c, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044f\u0432\u043d\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u043a\u0430\u043a \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0439 \u0441 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a>. \u042d\u0442\u0438\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0433\u0438\u043d <code>access.plugins.DjangoAccessPlugin<\/code>, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439, \u043a\u0430\u043a \u043f\u043b\u0430\u0433\u0438\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043b\u0430\u0433\u0438\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a <code>settings.py<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d, \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u044e\u0449\u0438\u0439\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u043a\u0440\u043e\u043c\u0435 \u0441\u0443\u043f\u0435\u0440\u0430\u0434\u043c\u0438\u043d\u0430, \u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e, \u043a\u0430\u043a \u043f\u043b\u0430\u0433\u0438\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">class SuperOnly(AccessPluginBase):     def check_visible(self, model, request):         return request.user.is_superuser and {}     def check_changeable(self, model, request):         return request.user.is_superuser and {}     def check_appendable(self, model, request):         return request.user.is_superuser and {}     def check_deleteable(self, model, request):         return request.user.is_superuser and {}<\/code><\/pre>\n<p>  <\/p>\n<p><code>settings.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">ACCESS_DEFAULT_PLUGIN = &quot;authorize.models.SuperOnly&quot;<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h1 id=\"rezyume\">\u0420\u0435\u0437\u044e\u043c\u0435<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a>, \u043c\u044b \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0434\u0435\u0442\u0430\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u043c\u043e\u0433\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u044b \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432 \u0444\u043e\u0440\u043c\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0421\u0423\u0411\u0414.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/nnseva\/django-access-sample-1\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitHub<\/a><\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/500142\/\"> https:\/\/habr.com\/ru\/post\/500142\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/500142\/\">\n<p>\u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 <a href=\"https:\/\/docs.djangoproject.com\/en\" rel=\"nofollow\">Django<\/a> \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c, \u0430 \u0442\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0438\u043f\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u0420\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u2014 \u0433\u0434\u0435-\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0430 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u2014 \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u0435\u0433\u043e \u0443\u0441\u043b\u0443\u0433. \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u2014 <a href=\"https:\/\/github.com\/nnseva\/django-access\" rel=\"nofollow\">Django-Access<\/a>. \u0412\u0441\u0435, \u043a\u043e\u043c\u0443 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0434 \u043a\u0430\u0442.<\/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-302923","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302923","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=302923"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302923\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}