Opened 10 years ago
Last modified 10 years ago
#24922 closed Bug
Templates: conflicting settings should emit a system check error — at Version 2
Reported by: | Sergei Maertens | Owned by: | Sergei Maertens |
---|---|---|---|
Component: | Core (System checks) | Version: | dev |
Severity: | Normal | Keywords: | templates, system check |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I discovered that specifying the templates settings as following, raises an error when rendering the template:
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], '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', ], 'loaders': [ ('django.template.loaders.cached.Loader', [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]), ], }, }, ]
urls.py:
from django.conf.urls import include, url from django.contrib import admin from django.views.generic import TemplateView urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', TemplateView.as_view(template_name='test.html')), ]
Test template is just an empty file
Error:
Environment: Request Method: GET Request URL: http://localhost:8000/ Django Version: 1.8.2 Python Version: 3.4.3 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles') Installed Middleware: ('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') Traceback: File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response 164. response = response.render() File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/response.py" in render 158. self.content = self.rendered_content File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/response.py" in rendered_content 133. template = self._resolve_template(self.template_name) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/response.py" in _resolve_template 88. new_template = self.resolve_template(template) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/response.py" in resolve_template 78. return loader.select_template(template, using=self.using) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/loader.py" in select_template 57. engines = _engine_list(using) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/loader.py" in _engine_list 144. return engines.all() if using is None else [engines[using]] File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/utils.py" in all 110. return [self[alias] for alias in self] File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/utils.py" in <listcomp> 110. return [self[alias] for alias in self] File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/utils.py" in __getitem__ 101. engine = engine_cls(params) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/backends/django.py" in __init__ 24. self.engine = Engine(self.dirs, self.app_dirs, **options) File "/home/bbt/coding/.virtualenvs/tpl_app_dirs/lib/python3.4/site-packages/django/template/engine.py" in __init__ 36. "app_dirs must not be set when loaders is defined.") Exception Type: ImproperlyConfigured at / Exception Value: app_dirs must not be set when loaders is defined.
Change History (2)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.