{"id":2068,"date":"2023-04-01T21:39:08","date_gmt":"2023-04-01T13:39:08","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2068"},"modified":"2023-04-06T16:01:59","modified_gmt":"2023-04-06T08:01:59","slug":"django-static-file-directory-configuration","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/django-static-file-directory-configuration\/","title":{"rendered":"Django\u9759\u6001\u6587\u4ef6\u76ee\u5f55\u914d\u7f6e"},"content":{"rendered":"<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/howto\/static-files\/\">https:\/\/docs.djangoproject.com\/en\/3.0\/howto\/static-files\/<\/a><\/p>\n<p>\u7f16\u8f91<code>setting.py<\/code>\uff1a<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-python\">INSTALLED_APPS = [\n    ...\n    &#039;django.contrib.staticfiles&#039;,\n]\n\n...\n\n# Static files (CSS, JavaScript, Images)\n# https:\/\/docs.djangoproject.com\/en\/3.0\/howto\/static-files\/\n\nSTATIC_URL = &#039;\/static\/&#039;\nSTATICFILES_DIRS = [\n    os.path.join(BASE_DIR, &quot;static&quot;),\n]<\/code><\/pre>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;zh&quot;&gt;\n{% load static %}\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, maximum-scale=1&quot;&gt;\n    &lt;title&gt;AppBlog.CN&lt;\/title&gt;\n\n    &lt;link href=&quot;{% static &#039;layui\/css\/layui.css&#039; %}&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; \/&gt;\n    &lt;script src=&quot;{% static &#039;layui\/layui.js&#039; %}&quot; type=&quot;text\/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;\/script&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\uff1ahttps:\/\/docs.djangoproject.com\/en\/3.0\/howto\/static-f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[522],"class_list":["post-2068","post","type-post","status-publish","format-standard","hentry","category-python","tag-django"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2068"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2068\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}