gpt4 book ai didi

python - 导入请求处理器模块 Django 时出错

转载 作者:太空狗 更新时间:2023-10-30 00:41:10 26 4
gpt4 key购买 nike

尝试在 Django settings.py 中配置 TEMPLATE_CONTEXT PROCESSORS 时出现以下错误:

        Exception Value: Error importing request processor module  
django.contrib.messages.context_processors.messagesdjango.core.context_processors:
"No module named 'django.contrib.messages.context_processors.messagesdjango';
django.contrib.messages.context_processors is not a package"

我的TEMPLATE_CONTEXT_PROCESSORS如下:(Django版本:1.5.1)

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages"
"django.core.context_processors.request",
)

最佳答案

在这两行之间包含 messages 后,您缺少一个逗号:

"django.contrib.messages.context_processors.messages"
"django.core.context_processors.request",

应该是:

"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request",

关于python - 导入请求处理器模块 Django 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17352636/

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