{{{ django.core.exceptions.ImproperlyConfigured: Requested setting CACHES,
but settings are not configured. You must either define the environment
variable DJANGO_SETTINGS_MODULE or call settings.configure() before
accessing settings. }}}.
As far I can tell the Jinja2 backend doesn't need a cache backend to be
configured.
--
Ticket URL: <https://code.djangoproject.com/ticket/25094>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
The dependency on the settings is a side effect of importing
`template.backends.utils.csrf_input_lazy` triggering the the import of
`middleware.csrf.get_token` then `utils.cache.patch_vary_headers` and
finally `core.cache.caches`.
Moving `get_token` (and maybe `rotate_token`) to a new module (maybe
`django.utils.csrf`?) would solve this. `get_token` is imported from at
various places throughout the Django codebase.
--
Ticket URL: <https://code.djangoproject.com/ticket/25094#comment:1>
Comment (by timgraham):
Could you explain the use case for importing the backend without settings
configured?
--
Ticket URL: <https://code.djangoproject.com/ticket/25094#comment:2>
Comment (by aaugustin):
We're trying to keep as many modules as possible importable without
requiring configured settings.
IIRC there was another ticket recently to stop accessing settings at
import time when importing `django.core.caches`. This is the correct
approach. The technique proposed here will fix the symptoms for
`template.backends.utils` but not for any other module that imports
`django.core.caches`. I recommend to close this as a duplicate of the
other ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/25094#comment:3>
* status: new => closed
* resolution: => duplicate
Comment:
Closing as a duplicate of #25034.
The use case for me was doing some benchmarking on jinja2 VS the cached
template loader. (Pretty similar in performance so far).
--
Ticket URL: <https://code.djangoproject.com/ticket/25094#comment:4>