2013-10-04 57 views
1

我找到了一个更好的错误信息(见下文)。NoReverseMatch:与参数 '(U' ')' 和关键字参数 '{}' 不found.in Django管理

我有一个核心/ models.py称为应用模型。尝试访问django admin中的特定应用程序对象时发生此错误。即使在一个空的数据库(syncdb后)与一个单一的应用程序对象。

似乎core_app_history是Django的产生的东西。任何帮助表示赞赏。

这里是个例外:

NoReverseMatch at /admin/core/app/251/ 
Reverse for 'core_app_history' with arguments '(u'',)' and keyword arguments '{}' not found. 
Request Method: GET 
Request URL: http://weblocal:8001/admin/core/app/251/ 
Django Version: 1.5.4 
Exception Type: NoReverseMatch 
Exception Value:  
Reverse for 'core_app_history' with arguments '(u'',)' and keyword arguments '{}' not found. 
Exception Location: /opt/virtenvs/django_slice/local/lib/python2.7/site-packages/django/template/defaulttags.py in render, line 426 
Python Executable: /opt/virtenvs/django_slice/bin/python 
Python Version: 2.7.3 
Python Path:  
['/opt/src/slicephone/cloud', 
'/opt/virtenvs/django_slice/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', 
'/opt/virtenvs/django_slice/local/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg', 
'/opt/virtenvs/django_slice/local/lib/python2.7/site-packages/distribute-0.6.35-py2.7.egg', 
'/opt/virtenvs/django_slice/lib/python2.7', 
'/opt/virtenvs/django_slice/lib/python2.7/plat-linux2', 
'/opt/virtenvs/django_slice/lib/python2.7/lib-tk', 
'/opt/virtenvs/django_slice/lib/python2.7/lib-old', 
'/opt/virtenvs/django_slice/lib/python2.7/lib-dynload', 
'/usr/lib/python2.7', 
'/usr/lib/python2.7/plat-linux2', 
'/usr/lib/python2.7/lib-tk', 
'/opt/virtenvs/django_slice/local/lib/python2.7/site-packages'] 
Server time: Fri, 11 Oct 2013 22:06:43 +0000 

32  <li><a href="{% url opts|admin_urlname:'history' original.pk|admin_urlquote %}" class="historylink">{% trans "History" %}</a></li> 

这里是(可能)相关的URL发生在/django/contrib/admin/templates/admin/change_form.html:

/admin/core/app/ HANDLER: changelist_view 
/admin/core/app/add/ HANDLER: add_view 
/admin/core/app/(.+)/history/ HANDLER: history_view 
/admin/core/app/(.+)/delete/ HANDLER: delete_view 
/admin/core/app/(.+)/ HANDLER: change_view 
+0

做所有其他意见工作? –

+0

显示你的应用程序的“views”和“urls”。 – sachitad

+0

@AryehLeibTaurog是的,所有其他视图和管理界面工作正常。 – kev

回答

0

我的猜测是你有一个视图引用了你的urlconf中的某个地方,它不能被导入,这个wo导致reverse失败。尝试颠倒shell中的不同视图。

+0

工作原理:reverse('app_owner') - >'/ core/app_owner /' – kev

0

这可能因与空的主键条目,如果你的模型有一个像

id = models.CharField(blank=True, primary_key=True) 
+0

我没有手动指定主键。 – kev

0

我会对此发表评论,因为我有完全一样的问题和领域可能出现这种情况引起这是我能找到的唯一一个指向正确方向的链接。其实它并没有指出我在正确的方向,但至少它让我感觉不那么孤单:)

注意我的代码,有时做的工作。实际上,我的错误代码在生产服务器上仍然很愉快。

我的问题是在管理我已经重写我的render_change_form。当我打电话超级方法,而不是做

return super(ReceiptAdmin, self).render_change_form(request, context, *args, **kwargs) 

我在不经意间做

return super(ReceiptAdmin, self).render_change_form(request, context, args, kwargs) 

我发现这一点时,我通过代码加强,发现什么正在通过我的父类的方法没有看对。它让我感到疑惑,为什么它有时会起作用。这个不正确的调用是从其他一些代码中复制并粘贴的,这些代码也在本地发生故障,但不在现场。

无论如何,有如果任何人任何用途。

相关问题