gpt4 book ai didi

django - 无法导入名称TEMPLATE_CONTEXT_PROCESSORS

转载 作者:行者123 更新时间:2023-12-03 14:47:27 28 4
gpt4 key购买 nike

我尝试使用virtualenv,而evrythings出错了...

我停用了所有virtualenv(使用deactavite)。

当我尝试启动时:python manage.py runserver
我收到此错误消息:

 Traceback (most recent call last):   File "manage.py", line 11, in
<module>
execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 367, in execute_from_command_line
utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 316, in execute
settings.INSTALLED_APPS File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line
53, in __getattr__
self._setup(name) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line
41, in _setup
> self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line
97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name) File "/home/jf/mysite/mysite/settings.py", line 68, in <module>
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP ImportError: cannot import name
TEMPLATE_CONTEXT_PROCESSORS

我自己的路
PYTHON_PATH =“/usr/lib/python2.7/dist-packages”

我的Django版本:1.10

settings.py文件
"""
Django settings for mysite project.

Generated by 'django-admin startproject' using Django 1.8.7.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'telo@^)(b_8j=s^507(u_zq)b71s$rcn=xl_r%36fs-e923*45'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [

'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# 'django_dynamic_views',
'teckno',
'polls',
'suit',
'django.contrib.admin',
'bootstrap3',
]

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
)

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['','teckno', 'demo'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
#'django.template.context_processors.debug',
#'django.template.context_processors.request',
#'django.contrib.auth.context_processors.auth',
#'django.contrib.messages.context_processors.messages',
#'django.template.context_processors.request',
"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',

],
},
},
]

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'fr-fr'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Modif

#STATIC_ROOT = "/home/jf/mysite/mysite"
ROOT_PATH = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(ROOT_PATH, 'static')

STATIC_URL = '/static/'

# MOFIF JF

# https://docs.djangoproject.com/fr/1.10/ref/settings/#append-slash
APPEND_SLASH=False

如果有人有主意,谢谢。

最佳答案

从您的设置中删除此行:

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP

在Django 1.8和 removed in Django 1.10中不推荐使用 TEMPLATE_CONTEXT_PROCESSORS。无法再导入它。

您已经在 context_processors设置中定义了 TEMPLATES,因此不再需要 TEMPLATE_CONTEXT_PROCESSORS

关于django - 无法导入名称TEMPLATE_CONTEXT_PROCESSORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39315348/

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