今天我将我的项目部署在托管服务器上,因为我也DEBUG = False
有内部服务器错误。完整的报告是:
/storage.py", line 280, in stored_name
cache_name = self.clean_name(self.hashed_name(name))
File "/home/ttipprotest/lib/python3.4/django/contrib/staticfiles
/storage.py", line 94, in hashed_name
(clean_name, self))
ValueError: The file 'css/styles.css' could not be found with
<django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at
0x7f2787c23ef0>.
开发中一切正常,但现在我一整天都在尝试解决这个问题。很抱歉显示错误消息。
编辑:
在产品设置中:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_URL = '/static/'
STATIC_ROOT = "/home/ttipprotest/webapps/ttipprotest_static/"
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static', 'our_static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = "/home/ttipprotest/webapps/ttipprotest_media/"
项目结构:
src
-ttipprotest
--manage.py
--settings
---base.py
---prod.py
-app 1
-...
-app n
-static
--our static
---css
---js
---fonts
-templates
第二次编辑:
每次渲染模板时都会出现问题。这是 index.html。我想这是这种行为的根源,因为我发现没有这个 index.html 的其他应用程序工作正常。
{% load staticfiles %}
{% load crispy_forms_tags %}