[Django] #24527: Using standalone templates gives confusing error message

12 views
Skip to first unread message

Django

unread,
Mar 23, 2015, 7:41:32 PM3/23/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------+-----------------------------------
Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords: templates, standalone
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------
I'm trying to use Django templates in "standalone" fashion, and I'm
getting the following `AppRegistryNotReady` error at bottom (with version
1.7.7).

The error is confusing because my understanding from
[https://docs.djangoproject.com/en/dev/topics/settings/#using-settings-
without-setting-django-settings-module the documentation] is that calling
the following is sufficient before using Django's template code:

{{{
django.conf.settings.configure()
}}}

Here is the stack trace:

{{{
File
"/Users/chris/dev/.virtualenvs/my_package/scripts/../pyelect/htmlgen.py",
line 171, in render_template
template = get_template(template_name, dirs=[])
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/template/loader.py", line 144, in get_template
template, origin = find_template(template_name, dirs)
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/template/loader.py", line 126, in find_template
loader = find_template_loader(loader_name)
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/template/loader.py", line 98, in find_template_loader
TemplateLoader = import_string(loader)
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/utils/module_loading.py", line 26, in import_string
module = import_module(module_path)
File
"/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/importlib/__init__.py",
line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in
_call_with_frames_removed
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/template/loaders/app_directories.py", line 33, in <module>
app_template_dirs = calculate_app_template_dirs()
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/template/loaders/app_directories.py", line 21, in
calculate_app_template_dirs
for app_config in apps.get_app_configs():
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/Users/chris/dev/.virtualenvs/my_package/lib/python3.4/site-
packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.


}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24527>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 23, 2015, 7:52:58 PM3/23/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: templates, | Triage Stage:
standalone | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by cjerdonek):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Investigating further, it looks like this is because
`django.template.loaders.app_directories.Loader` is part of the default
`TEMPLATE_LOADERS` setting. But the
[https://docs.djangoproject.com/en/1.7/ref/templates/api/#configuring-the-
template-system-in-standalone-mode documentation for using templates in
standalone] doesn't say this setting needs to be manually set.

--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:1>

Django

unread,
Mar 24, 2015, 5:06:57 AM3/24/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: templates, | Triage Stage:
standalone | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

In addition to configuring the settings, you must call `django.setup()`.

The documentation could be improved.

--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:2>

Django

unread,
Mar 24, 2015, 6:59:36 AM3/24/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: templates, | Triage Stage:
standalone | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by cjerdonek):

Strictly speaking, it's possible you might not ''need'' to call
`django.setup()`. (I'm pretty sure I was able to get things workings by
setting `TEMPLATE_LOADERS` only to use the file loader.) However, once I
started using `include` I started running into problems again (I believe
because that causes `get_template()` to be called without the `dirs`
argument.)

--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:3>

Django

unread,
Mar 25, 2015, 10:00:51 AM3/25/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: templates, | Triage Stage: Accepted
standalone |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* component: Uncategorized => Documentation
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:4>

Django

unread,
Jul 12, 2015, 11:28:46 AM7/12/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: templates, | Triage Stage: Accepted
standalone |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ubernostrum):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:5>

Django

unread,
Jul 22, 2015, 8:18:44 AM7/22/15
to django-...@googlegroups.com
#24527: Using standalone templates gives confusing error message
-------------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: duplicate

Keywords: templates, | Triage Stage: Accepted
standalone |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => duplicate


Comment:

Seems to me this is addressed by the docs added in #25156.

--
Ticket URL: <https://code.djangoproject.com/ticket/24527#comment:6>

Reply all
Reply to author
Forward
0 new messages