gpt4 book ai didi

python - 在 Django 中运行测试时出现 NoReverseMatch 错误

转载 作者:太空宇宙 更新时间:2023-11-04 06:15:31 24 4
gpt4 key购买 nike

我正在使用 python django我在运行 tests.py 时出错这是什么意思:

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。

也许 adingcomment 是一个拼写错误,应该用 addingcomment 代替?

关于python - 在 Django 中运行测试时出现 NoReverseMatch 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15953287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com