{"id":295822,"date":"2019-12-17T16:28:28","date_gmt":"2019-12-17T16:28:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295822"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295822","title":{"rendered":"Django vue generator"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/479654\/\">\u041a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 rest framework \u0441 vue? \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0441 django \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 vue \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e vue-cli. \u041f\u0435\u0440\u0435\u0439\u0434\u044f \u0432 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0431\u0440\u0430\u0432 yarn build, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 dist \u0444\u0430\u0439\u043b\u044b index.html \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 css \u0438 js. \u0410\u0433\u0430, css \u0438 js \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 static, \u0430 \u0438\u0437 index.html \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d. <a name=\"habracut\"><\/a>\u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441 \u0444\u0440\u043e\u043d\u0442\u043e\u043c(\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u043d\u0430\u0437\u0432\u0430\u043b\u0438 \u0435\u0433\u043e frontend) \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 static\/frontend \u0438 templates\/frontend \u0438 \u0444\u0430\u0439\u043b\u044b __init__.py \u0438 urls.py, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c frontend \u0432 INSTALLED_APPS. \u0412 urls.py \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 <code>path('', TemplateView.as_view(template_name='frontend\/index.html'), name='frontend-index'),<\/code><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438 \u043a\u0443\u0434\u0430 \u043d\u0430\u0434\u043e, \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c build \u0432 package.json \u043d\u0430 <code>\"vue-cli-service build &amp;&amp; (rm -rf static\/frontend\/ 2&gt;\/dev\/null || true) &amp;&amp; sed 's\/=\\\\\/\/=\\\\\/static\\\\\/frontend\\\\\/\/g' dist\/index.html &gt; templates\/frontend\/index.html &amp;&amp; mv dist static\/frontend\"<br \/>  <\/code> \u0417\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u0443\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e sed.<\/p>\n<p>  \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u044f \u0441\u0434\u0435\u043b\u0430\u043b <a href=\"https:\/\/github.com\/pawnhearts\/django_vue_generator\">django_vue_generator<\/a>. \u041e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 management-\u043a\u043e\u043c\u043c\u0430\u043d\u0434\u044b start_frontend \u0438 build_frontend. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0451! \u041e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0442 \u0444\u043e\u0440\u043c\u044b \u0441 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 serializer`\u043e\u0432. \u0418 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u043c\u0438 \u0434\u043b\u044f viewset`\u043e\u0432 drf \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0418 list-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043d\u0438\u0445 \u0436\u0435. \u0421 \u043f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u0435\u0439 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ei\/dc\/9z\/eidc9zcmhpkxsreye_ccvhd3tao.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ib\/ql\/jt\/ibqljtoh_u4dwfjm7t8h8j8cups.png\"><\/p>\n<p>  \u0412\u0438\u0434 \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e slots.<\/p>\n<p>  \u0412 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0438\u0434\u0435\u0442 \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c run.sh, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/post\/479654\/\"> https:\/\/habr.com\/ru\/post\/479654\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/479654\/\">\u041a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 rest framework \u0441 vue? \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0441 django \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 vue \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e vue-cli. \u041f\u0435\u0440\u0435\u0439\u0434\u044f \u0432 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0431\u0440\u0430\u0432 yarn build, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 dist \u0444\u0430\u0439\u043b\u044b index.html \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 css \u0438 js. \u0410\u0433\u0430, css \u0438 js \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 static, \u0430 \u0438\u0437 index.html \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d. <\/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-295822","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295822","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=295822"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295822\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}