关于python:django-admin-sortable get_do_sorting_url上的NoReverseMatch错误

django-admin-sortable NoReverseMatch error on get_do_sorting_url

我正在尝试使用django-admin-sortable,但是一旦我保存了一个对象并尝试在Admin界面中加载它,我就会在adminsortable / edit_inline / tabular.html模板的第43行获得NoReverseMatch。

我真的不知道我做错了什么。

我正在使用Python 2.7Django 1.4。 我从pip安装了django-admin-sortable。

下面是堆栈跟踪输出。

Environment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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))

1
2
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.


新版本的django-admin-sortable - 1.3.6包含对传递给get_do_sorting_url模板标记的值中的错误的修复。

[编辑]

因此,在使用原始海报之后,事实证明这是django-admin-sortable中的一个已知问题:内联目前无法在不从可排序继承的模型中进行排序。