error in templatetag with Django 1.8
Closed this issue · 2 comments
stefanfoulis commented
Environment:
Request Method: GET
Request URL: http://appctl.local.aldryn.net/admin/app_controller/host/05a88020-9587-4207-9ed0-b02d39f5fe96/
Django Version: 1.8.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'app_controller',
'rest_framework',
'rest_framework.authtoken',
'gunicorn',
'relatives')
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 /usr/local/lib/python2.7/dist-packages/relatives/templates/relatives/change_form.html, error at line 8
tuple index out of range
1 : {% extends "admin/change_form.html" %}
2 :
3 : {% block content %}
4 :
5 : <div id="content-main">
6 :
7 : {% load relatives %}
8 : {% related_objects adminform.form.instance as related_objects %}
9 : <div class="module grp-module" id="filter">
10 : {% block relations %}
11 : <h2>Relations</h2>
12 : <ul>
13 : {% for related in related_objects %}
14 : <li><a href="{{ related.url }}">
15 : {{ related.plural_name|capfirst }}
16 : </a></li>
17 : {% endfor %}
18 : {% endblock relations %}
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
164. response = response.render()
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in render
158. self.content = self.rendered_content
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in rendered_content
135. content = template.render(context, self._request)
File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in render
74. return self.template.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
209. return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
201. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
135. return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
201. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
135. return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
201. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
135. return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
201. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
1227. context[self.target_var] = func(*resolved_args, **resolved_kwargs)
File "/usr/local/lib/python2.7/dist-packages/relatives/templatetags/relatives.py" in related_objects
61. *related.name.split(':')))
Exception Type: IndexError at /admin/app_controller/host/05a88020-9587-4207-9ed0-b02d39f5fe96/
Exception Value: tuple index out of range
treyhunner commented
Thank you for reporting this @stefanfoulis! I am not currently running this app on Django 1.8.
My suggestion for you or anyone who would like to update this app to work with 1.8:
- Update the
tox.ini
file to addpy27-1.8
,py33-1.8
, orpy34-1.8
(both at the top of the file and as a new section in the file) - Run the tests (see contributing file)
- Fix one test at a time
fizista commented
Hi...
I fixed some tests and a library part. I also added a test project that can help improve error in Django 1.8 / 1.9.
Unfortunately I do not have time to correct these tests:
ERROR: test_foreign_keys (relatives.tests.tests.RelatedObjectsTagTest)
ERROR: test_many_to_many (relatives.tests.tests.RelatedObjectsTagTest)
ERROR: test_no_admin_url (relatives.tests.tests.RelatedObjectsTagTest)
FAIL: test_add_form_for_non_nullable_fk (relatives.tests.tests.TemplateFilterTest)
FAIL: test_nullable_foreign_key (relatives.tests.tests.TemplateFilterTest)
Maybe someone will find time to complete the code migration to new versions of Django.
I also added a test site, making it easier to probably complete the migration:
cd relatives/tests/
./manage.py migrate
./manage.py createsuperuser --username admin --email admin@example.com
./manage.py runserver