我尝试使用 django-admin-sortable ,但是一旦我保存了一个对象并尝试在管理界面中加载它,我就会在第43行获得 NoReverseMatch adminsortable / edit_inline / tabular.html 模板。
我真的不知道自己做错了什么。
我正在使用Python 2.7
和Django 1.4
。我从pip安装了django-admin-sortable。
下面是堆栈跟踪输出。
环境:
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"
在渲染中 123. return compiled_parent._render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在_render 134. return self.nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py" 在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"在渲染中 123. return compiled_parent._render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在_render 134. return self.nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"在渲染中 62. result = block.nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"在渲染中 62. result = block.nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py"在渲染中 185. nodelist.append(node.render(context)) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"在渲染中 166.返回self.render_template(模板,上下文) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/loader_tags.py"在render_template中 137. output = template.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 140. return self._render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在_render 134. return self.nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py"在渲染中 185. nodelist.append(node.render(context)) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/defaulttags.py"在渲染中 281. return nodelist.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 823. bit = self.render_node(node,context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/debug.py"在render_node中 74. return node.render(context) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/template/base.py"在渲染中 1107. return func(* resolved_args,** resolved_kwargs) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/adminsortable/templatetags/adminsortable_tags.py"在get_do_sorting_url中 40.返回反向(&#39; admin:%s_do_sorting&#39;%obj._meta.app_label,kwargs = {&#39; model_type_id&#39;:obj.model_type_id()}) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/core/urlresolvers.py"相反 476. return iri_to_uri(resolver._reverse_with_prefix(view,prefix,* args,** kwargs)) 文件&#34; /home/josh/.virtualenvs/vvreports/local/lib/python2.7/site-packages/django/core/urlresolvers.py"在_reverse_with_prefix中 396.&#34;论证&#39;%s&#39;没找到。&#34; %(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.
答案 0 :(得分:2)
新版本的django-admin-sortable - 1.3.6包含对传递给get_do_sorting_url模板标记的值中的错误的修复。
[编辑]
因此,在使用原始海报之后,事实证明这是django-admin-sortable中的known issue:内联目前无法在不从可排序继承的模型中进行排序。