2
votes

I'm trying to use django-admin-sortable but once I save an object and try to load it in the Admin interface I get a NoReverseMatch on line 43 of the adminsortable/edit_inline/tabular.html template.

I really have no clue what I've done wrong.

I'm using Python 2.7 and Django 1.4. I installed django-admin-sortable from pip.

Below is stack trace output.

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/reports/reportsuser/7/

Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'functional_tests',
 'reports',
 'adminsortable')
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 /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/adminsortable/templates/adminsortable/edit_inline/tabular.html, error at line 43 Reverse for 'reports_do_sorting' with arguments '()' and keyword arguments '{'model_type_id': 44L}' not found.
   33 :           {% spaceless %}


   34 :           {% for fieldset in inline_admin_form %}


   35 :             {% for line in fieldset %}


   36 :               {% for field in line %}


   37 :                 {% if field.is_hidden %} {{ field.field }} {% endif %}


   38 :               {% endfor %}


   39 :             {% endfor %}


   40 :           {% endfor %}


   41 :           {% endspaceless %}


   42 :           {% if inline_admin_form.original %}


   43 :           <input type="hidden" name="admin_sorting_url" value=" {% get_do_sorting_url inline_admin_form.original %} " />


   44 :           {% endif %}


   45 :         </td>


   46 :         {% for fieldset in inline_admin_form %}


   47 :           {% for line in fieldset %}


   48 :             {% for field in line %}


   49 :               <td class="{{ field.field.name }}">


   50 :               {% if field.is_readonly %}


   51 :                   <p>{{ field.contents }}</p>


   52 :               {% else %}


   53 :                   {{ field.field.errors.as_ul }}


Traceback:
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  136.                     response = response.render()
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/response.py" in render
  104.             self._set_content(self.rendered_content)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  81.         content = template.render(context)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"

in render 123. return compiled_parent._render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 123. return compiled_parent._render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 62. result = block.nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 62. result = block.nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render 185. nodelist.append(node.render(context)) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 166. return self.render_template(template, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render_template 137. output = template.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 140. return self._render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render 185. nodelist.append(node.render(context)) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render 281. return nodelist.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 823. bit = self.render_node(node, context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py" in render_node 74. return node.render(context) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" in render 1107. return func(*resolved_args, **resolved_kwargs) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/adminsortable/templatetags/adminsortable_tags.py" in get_do_sorting_url 40. return reverse('admin:%s_do_sorting' % obj._meta.app_label, kwargs={'model_type_id': obj.model_type_id() }) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse 476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)) File "/home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix 396. "arguments '%s' not found." % (lookup_view_s, args, kwargs))

Exception Type: NoReverseMatch at /admin/reports/reportsuser/7/
Exception Value: Reverse for 'reports_do_sorting' with arguments '()' and keyword arguments '{'model_type_id': 44L}' not found.
1
I'd guess it has something to do with get_do_sorting_url. That doesn't seem to be a part of django-admin-sortable, is it something you wrote?Nathan Villaescusa
It is part of django-admin-sortable, adminsortable.templatetags.adminsortable_tags.get_do_sorting_urlcellofellow

1 Answers

3
votes

A new version of django-admin-sortable - 1.3.6 includes a fix for an error in the value that was being passed to the get_do_sorting_url template tag.

[EDIT]

So, after working with the original poster, it turns out this is a known issue in django-admin-sortable: inlines can't currently be sortable within a model that doesn't inherit from sortable.