晚上好,我的django项目遇到了一个奇怪的问题。从我开始开发它的Ubuntu上,我没有发现任何问题,但是当我尝试在OS X El Capitan中移动它时,我要么收到以下错误之一:
1)当APP_DIRS
设置为True
时:定义装载程序时,不得设置app_dirs
。
2)当APP_DIRS
设置为False
或已删除时:没有名为'admin_tools.template_loaders'的模块
在这个settings.py中我有什么不好的事情吗?
这就是我的settings.py的样子:
SITE_ID = 1
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'tinymce',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'management',
'myApp',
'easy_thumbnails',
)
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,spellchecker,paste,searchreplace",
'theme': "advanced",
'cleanup_on_startup': True,
'custom_undp_redo_levels': 10,
}
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 = 'myproject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'debug': DEBUG,
'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.core.context_processors.request',
'django.template.context_processors',
],
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
'admin_tools.template_loaders.Loader',
]
},
},
]
WSGI_APPLICATION = 'myproject.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
AUTH_USER_MODEL = 'management.IfasicUser'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
LOGIN_URL = 'django.contrib.auth.views.login'
LOGIN_REDIRECT_URL = 'home'
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
CRISPY_TEMPLATE_PACK = 'bootstrap3'
任何帮助将不胜感激。
最佳答案
当App_DIRS
设置为True
时:定义装载程序时,不得设置app_dirs
。
如错误所示,定义app_dirs
时必须删除loaders
设置。
当APP_DIRS
设置为False
或已删除时:没有名为'admin_tools.template_loaders'的模块
尝试升级到今天发布的0.7.1。查看the changelog,缓存的模板加载器似乎存在一个错误。
关于python - Settings.py无法按预期工作Django,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33963288/