gpt4 book ai didi

django - appfog django 静态文件

转载 作者:行者123 更新时间:2023-12-01 19:50:00 25 4
gpt4 key购买 nike

我有一个项目,实际上是来自 appfog ( https://github.com/appfog/af-python-django ) 的测试,在本地主机上运行顺利。但它不起作用,至少一旦部署在appfog上就无法识别静态文件。我只是更改了模板的位置。

这是测试页http://st-test.eu01.aws.af.cm/ .同样,管理页面也没有 css http://st-test.eu01.aws.af.cm/admin/

这是我的配置(setting.py)

STATIC_ROOT = ''

STATIC_URL = '/static/'

STATICFILES_DIRS = (
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

我也试过

STATIC_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static')

但没有任何变化。

我试过在本地执行 collectstatic,然后更新存储库中的文件,但没有任何效果。

你们中有人知道如何让它工作吗?

顺便说一句,在模板中我使用了 {% load staticfiles %}{% static "css/style.css"%}

最佳答案

这对我有用:

设置.py:

import os
ROOT_PATH = os.path.dirname(__file__)

STATIC_ROOT = os.path.join(ROOT_PATH, 'static')
STATIC_URL = '/static/'

urls.py:

(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),

关于django - appfog django 静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13379103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com