【发布时间】:2016-04-13 13:54:34
【问题描述】:
我对 Django 有一点问题,它不是我的静态文件。 我已经阅读了文档,我尝试直接放置路径,使用 {{ STATIC_URL }},最推荐的方法是留下细节。知道如何解决吗? 模板.html:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/normalize.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/demo.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/component.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/cs-select.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/cs-skin-boxes.css' %}" />
local.py(设置)
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR2.child('static')]
我的文件夹在正确的方向 The first folder is the virtualenv, the second folder is for Django Project where is the manage.py (image)
视图、模型、网址和表单正常工作,并显示所选模板 [python代码正常运行(图)][2]
更新
我尝试为此更改 STATICFILES_DIRS:
STATICFILES_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), 'static', ),
)
并打印路径以确保它正确,但错误仍在继续。 The result of print 提前致谢
【问题讨论】:
-
我为 Django 1.9 解决的问题是:
STATICFILES_DIRS = (BASE_DIR, 'static')
标签: python django-templates django-staticfiles