在Django中运行测试时出现NoReverseMatch错误 [英] NoReverseMatch error when running tests in Django
本文介绍了在Django中运行测试时出现NoReverseMatch错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用python django我在运行tests.py时出错这是什么意思:
i'm using python django i had error while running the tests.py what does that mean :
Traceback (most recent call last):
File "/home/hala/Desktop/lasting/sharesoft-13/project/tager/tager_www/tests.py", line 82, in test_saving_comments
response=c.get(reverse('adingcomment', kwargs={'post_id' : 1, 'content':'hjhgh'}))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 496, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 416, in _reverse_with_prefix
"arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for 'adingcomment' with arguments '()' and keyword arguments '{'content': 'hjhgh', 'post_id': 1}' not found.
推荐答案
这意味着Django无法找到与该特定路径名和参数匹配的路由,因此无法通过反转该路由来生成URL.
It means that Django was unable to find a route which would match that particular path name and arguments, and thus was unable to generate a URL by reversing the route.
也许 adingcomment
是一个错字,应该是 addingcomment
吗?
Perhaps adingcomment
was a typo, and should have been addingcomment
instead?
这篇关于在Django中运行测试时出现NoReverseMatch错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文