praekelt/django-object-tools — pull request #1 by qoda (2014-09-15 11:44:22+00:00)
Title: change_list.html{62} {%object_tools cl.model request.user%} VariableDoesNotExist

Using django-object-tools with django-1.4 http://code.djangoproject.com/svn/django/trunk@16680 (via git mirror), I get an error:

Template error
In template /software/django-object-tools/object_tools/templates/admin/change_list.html, error at line 62
TemplateSyntaxError at /admin/myapp/mymodel/
Caught VariableDoesNotExist while rendering

I have configured django-object-tools as directed:

--- a/src/settings/settings/__init__.py
+++ b/src/settings/settings/__init__.py
@@ -120,6 +120,7 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'object_tools',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
Modified src/settings/settings/urls.py
diff --git a/src/settings/settings/urls.py b/src/settings/settings/urls.py
index 7ad469b..0f7ba57 100644
--- a/src/settings/settings/urls.py
+++ b/src/settings/settings/urls.py
@@ -1,5 +1,9 @@
from django.conf.urls.defaults import patterns, include, url

+import object_tools
+
+object_tools.autodiscover()
+
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
@@ -13,5 +17,6 @@ urlpatterns = patterns('',
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
+ url(r'^object-tools/', include(object_tools.tools.urls)),
url(r'^admin/', include(admin.site.urls)),
)

Traceback information below:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:1337/admin/myapp/mymodel/

Django Version: 1.4 pre-alpha
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'object_tools',
'django.contrib.admin',
'myapp',
'devserver',
'gunicorn']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Template error:
In template /software/django-object-tools/object_tools/templates/admin/change_list.html, error at line 62

Caught VariableDoesNotExist while rendering: Failed lookup for key [request] in u'[{\'actions_on_bottom\': False, \'cl\': , \'has_add_permission\': True, \'actions_selection_counter\': True, \'actions_on_top\': True, \'selection_note\': u\'0 of 20 selected\', \'is_popup\': False, \'selection_note_all\': u\'All 36 selected\', \'media\': , \'title\': u\'Select mymodel to change\', \'action_form\': , \'app_label\': \'myapp\', \'module_name\': u\'mymodels\'}, {\'csrf_token\': }, {\'perms\': , \'user\': }, {}, {\'LANGUAGES\': ((\'ar\', \'Arabic\'), (\'az\', \'Azerbaijani\'), (\'bg\', \'Bulgarian\'), (\'bn\', \'Bengali\'), (\'bs\', \'Bosnian\'), (\'ca\', \'Catalan\'), (\'cs\', \'Czech\'), (\'cy\', \'Welsh\'), (\'da\', \'Danish\'), (\'de\', \'German\'), (\'el\', \'Greek\'), (\'en\', \'English\'), (\'en-gb\', \'British English\'), (\'es\', \'Spanish\'), (\'es-ar\', \'Argentinian Spanish\'), (\'es-mx\', \'Mexican Spanish\'), (\'es-ni\', \'Nicaraguan Spanish\'), (\'et\', \'Estonian\'), (\'eu\', \'Basque\'), (\'fa\', \'Persian\'), (\'fi\', \'Finnish\'), (\'fr\', \'French\'), (\'fy-nl\', \'Frisian\'), (\'ga\', \'Irish\'), (\'gl\', \'Galician\'), (\'he\', \'Hebrew\'), (\'hi\', \'Hindi\'), (\'hr\', \'Croatian\'), (\'hu\', \'Hungarian\'), (\'id\', \'Indonesian\'), (\'is\', \'Icelandic\'), (\'it\', \'Italian\'), (\'ja\', \'Japanese\'), (\'ka\', \'Georgian\'), (\'km\', \'Khmer\'), (\'kn\', \'Kannada\'), (\'ko\', \'Korean\'), (\'lt\', \'Lithuanian\'), (\'lv\', \'Latvian\'), (\'mk\', \'Macedonian\'), (\'ml\', \'Malayalam\'), (\'mn\', \'Mongolian\'), (\'nl\', \'Dutch\'), (\'nb\', \'Norwegian Bokmal\'), (\'nn\', \'Norwegian Nynorsk\'), (\'pa\', \'Punjabi\'), (\'pl\', \'Polish\'), (\'pt\', \'Portuguese\'), (\'pt-br\', \'Brazilian Portuguese\'), (\'ro\', \'Romanian\'), (\'ru\', \'Russian\'), (\'sk\', \'Slovak\'), (\'sl\', \'Slovenian\'), (\'sq\', \'Albanian\'), (\'sr\', \'Serbian\'), (\'sr-latn\', \'Serbian Latin\'), (\'sv\', \'Swedish\'), (\'ta\', \'Tamil\'), (\'te\', \'Telugu\'), (\'th\', \'Thai\'), (\'tr\', \'Turkish\'), (\'uk\', \'Ukrainian\'), (\'ur\', \'Urdu\'), (\'vi\', \'Vietnamese\'), (\'zh-cn\', \'Simplified Chinese\'), (\'zh-tw\', \'Traditional Chinese\')), \'LANGUAGE_BIDI\': False, \'LANGUAGE_CODE\': \'en-us\'}, {\'MEDIA_URL\': \'http://myapp.acme.com/media/\'}, {\'STATIC_URL\': \'http://myapp.acme.com/static/\'}, {\'messages\': }, {\'block\': , , ,

]>,

, ,

\n \'>, ]>,

, ]>,

, , ,

]>,

\n \'>, ,

\n \'>]>}]'
52 : {% endif %}

53 :

54 : {% block coltype %}flex{% endblock %}

55 :

56 : {% block content %}

57 :

58 : {% block object-tools %}

59 : {% if has_add_permission %}

60 :

61 : {% block object-tools-items %}

62 : {% object_tools cl.model request.user %}

63 :

64 :

65 : {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}

66 :

67 :

68 : {% endblock %}

69 :

70 : {% endif %}

71 : {% endblock %}

72 : {% if cl.formset.errors %}

Traceback:
File "/software/django/django/core/handlers/base.py" in get_response
136. response = response.render()
File "/software/django/django/template/response.py" in render
112. self._set_content(self.rendered_content)
File "/software/django/django/template/response.py" in rendered_content
89. content = template.render(context)
File "/software/django/django/template/base.py" in render
122. return self._render(context)
File "/software/django/django/template/base.py" in _render
116. return self.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/loader_tags.py" in render
125. return compiled_parent._render(context)
File "/software/django/django/template/base.py" in _render
116. return self.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/loader_tags.py" in render
125. return compiled_parent._render(context)
File "/software/django/django/template/base.py" in _render
116. return self.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/defaulttags.py" in render
328. return self.nodelist_true.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/software/django/django/template/base.py" in render
745. bits.append(self.render_node(node, context))
File "/software/django/django/template/debug.py" in render_node
72. result = node.render(context)
File "/software/django/django/template/base.py" in render
978. resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
File "/software/django/django/template/base.py" in resolve
652. value = self._resolve_lookup(context)
File "/software/django/django/template/base.py" in _resolve_lookup
691. raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute

Exception Type: TemplateSyntaxError at /admin/myapp/mymodel/
Exception Value: Caught VariableDoesNotExist while rendering: Failed lookup for key [request] in u'[{\'actions_on_bottom\': False, \'cl\': , \'has_add_permission\': True, \'actions_selection_counter\': True, \'actions_on_top\': True, \'selection_note\': u\'0 of 20 selected\', \'is_popup\': False, \'selection_note_all\': u\'All 36 selected\', \'media\': , \'title\': u\'Select mymodel to change\', \'action_form\': , \'app_label\': \'mymodel\', \'module_name\': u\'mymodels\'}, {\'csrf_token\': }, {\'perms\': , \'user\': }, {}, {\'LANGUAGES\': ((\'ar\', \'Arabic\'), (\'az\', \'Azerbaijani\'), (\'bg\', \'Bulgarian\'), (\'bn\', \'Bengali\'), (\'bs\', \'Bosnian\'), (\'ca\', \'Catalan\'), (\'cs\', \'Czech\'), (\'cy\', \'Welsh\'), (\'da\', \'Danish\'), (\'de\', \'German\'), (\'el\', \'Greek\'), (\'en\', \'English\'), (\'en-gb\', \'British English\'), (\'es\', \'Spanish\'), (\'es-ar\', \'Argentinian Spanish\'), (\'es-mx\', \'Mexican Spanish\'), (\'es-ni\', \'Nicaraguan Spanish\'), (\'et\', \'Estonian\'), (\'eu\', \'Basque\'), (\'fa\', \'Persian\'), (\'fi\', \'Finnish\'), (\'fr\', \'French\'), (\'fy-nl\', \'Frisian\'), (\'ga\', \'Irish\'), (\'gl\', \'Galician\'), (\'he\', \'Hebrew\'), (\'hi\', \'Hindi\'), (\'hr\', \'Croatian\'), (\'hu\', \'Hungarian\'), (\'id\', \'Indonesian\'), (\'is\', \'Icelandic\'), (\'it\', \'Italian\'), (\'ja\', \'Japanese\'), (\'ka\', \'Georgian\'), (\'km\', \'Khmer\'), (\'kn\', \'Kannada\'), (\'ko\', \'Korean\'), (\'lt\', \'Lithuanian\'), (\'lv\', \'Latvian\'), (\'mk\', \'Macedonian\'), (\'ml\', \'Malayalam\'), (\'mn\', \'Mongolian\'), (\'nl\', \'Dutch\'), (\'nb\', \'Norwegian Bokmal\'), (\'nn\', \'Norwegian Nynorsk\'), (\'pa\', \'Punjabi\'), (\'pl\', \'Polish\'), (\'pt\', \'Portuguese\'), (\'pt-br\', \'Brazilian Portuguese\'), (\'ro\', \'Romanian\'), (\'ru\', \'Russian\'), (\'sk\', \'Slovak\'), (\'sl\', \'Slovenian\'), (\'sq\', \'Albanian\'), (\'sr\', \'Serbian\'), (\'sr-latn\', \'Serbian Latin\'), (\'sv\', \'Swedish\'), (\'ta\', \'Tamil\'), (\'te\', \'Telugu\'), (\'th\', \'Thai\'), (\'tr\', \'Turkish\'), (\'uk\', \'Ukrainian\'), (\'ur\', \'Urdu\'), (\'vi\', \'Vietnamese\'), (\'zh-cn\', \'Simplified Chinese\'), (\'zh-tw\', \'Traditional Chinese\')), \'LANGUAGE_BIDI\': False, \'LANGUAGE_CODE\': \'en-us\'}, {\'MEDIA_URL\': \'http://myapp.acme.com/media/\'}, {\'STATIC_URL\': \'http://myapp.acme.com/static/\'}, {\'messages\': }, {\'block\': , , ,

]>,

, ,

\n \'>, ]>,

, ]>,

, , ,

]>,

\n \'>, ,

\n \'>]>}]'

Thanks