2

今天我将我的项目部署在托管服务器上,因为我也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 %}
4

1 回答 1

3

在我进行编辑时发现了错误。

index.html

{% load staticfiles %}

与 .完美配合DEBUG = True。至少它正在渲染和显示模板,但在显示错误的日志文件中。index.html是大多数其他模板扩展的模板。

在我将 index.html 更改为:

{% load static %}

它工作正常DEBUG = False

于 2016-07-12T09:09:39.940 回答