0
我正在使用cookiecutter django模板开发一个项目:https://github.com/pydanny/cookiecutter-django 该项目在docker容器中运行,该容器随ubuntu 16.04LTS上的cookiecutter-django模板提供。找不到Django静态文件数值错误
当试图让现场制作,它会返回在一些网页上出现以下错误:
the file 'events\css\themes\fontawesome-stars.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f830be38ac8>.
文件夹结构是:在码头工人的构建过程和后报告
./project/events/static/
└── events
├── css
├── details.css
├── list.css
└── themes
├── fontawesome-stars.css
└── fontawesome-stars-o.css
没有错误运行collectstatic。服务器上的文件 权限设置为775
在base.py配置静态配置:
# STATIC FILE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = [
str(APPS_DIR.path('static')),
]
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
在模板我包括像这样:
{% load static %}
{% load crispy_forms_tags %}
{% block title %}
{% endblock%}
{% block css %}
{{block.super}}
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="{% static 'events\css\themes\fontawesome-stars.css' %}">
{% endblock %}
我已经包含了与你建议应该完成的相同的方式。 将静态更改为静态文件不会改变任何内容。 – MarkerDave
@Niikhawod在刚刚添加的示例中,您使用的是“\”而不是“/”。这可能是问题所在。 – dethos
太棒了,如果那是问题所在。我的答案应该是正确的。 – dethos