gpt4 book ai didi

python - 将我的设置更改为 DEBUG = False 后发生的错误

转载 作者:行者123 更新时间:2023-11-28 17:34:11 28 4
gpt4 key购买 nike

我已经安装了 grapelli 管理主题,我还为我的模板使用了各种 javascript 文件。

一切都运行良好,在完成所有各种测试后,我决定尝试在我的设置文件中设置DEBUG = False

在我遇到 grapelli 的各种文件以及我自己的一些文件的 404 问题后立即。

为什么会这样,我开始怀疑我必须在我的应用程序模板中添加所有 grapelli(使用 pip 安装,位于 Python27 上)。

在使用各种外部模块的 Django 应用程序上准备生产的过程是什么?

编辑

因为这些与我的静态文件有关,所以很可能我应该包括我的静态文件设置

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = "/static/"

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

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

最佳答案

我认为你需要运行

python manage.py collectstatic

并设置静态文件的设置。在运行 collectstatic 后,您实际上可以在 STATIC ROOT 目录中看到 grapelli 文件夹。阅读 django docs此处了解更多详情。

确保你没有添加

static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

DEBUG == True 条件下到您的 url。

关于python - 将我的设置更改为 DEBUG = False 后发生的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32026935/

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