相关疑难解决方法(0)

Django staticfiles应用程序帮助

我对Django的staticfiles应用程序有一些小问题.

我已经添加了

'django.contrib.staticfiles',
Run Code Online (Sandbox Code Playgroud)

到我的INSTALLED_APPS并添加了

STATIC_URL = '/static/'
STATIC_ROOT = '/Users/kevdotbadger/django/mylook/static/'
Run Code Online (Sandbox Code Playgroud)

到我的settings.py档案.

我的所有静态文件都位于STATIC_ROOTMac上的文件夹中.

现在,在我使用的模板中

{{ STATIC_URL }}
Run Code Online (Sandbox Code Playgroud)

正确呈现的/static/.

然而

{{ STATIC_URL }}css/style.css
Run Code Online (Sandbox Code Playgroud)

导致404错误.我正在使用'runserver'命令作为服务器.

有什么我想念的吗?

python django static http-status-code-404

41
推荐指数
2
解决办法
3万
查看次数

标签 统计

django ×1

http-status-code-404 ×1

python ×1

static ×1