Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django:为什么一个空的queryset会触发NoReverseMatch异常?_Python_Django_Django Queryset - Fatal编程技术网

Python django:为什么一个空的queryset会触发NoReverseMatch异常?

Python django:为什么一个空的queryset会触发NoReverseMatch异常?,python,django,django-queryset,Python,Django,Django Queryset,我的模型url模式如下所示: url(r'^models/(?P<pk>\d+)/$', views.ThreediModelView.as_view(), name='models'), 回溯 NoReverseMatch at /models/models/9999/ Reverse for 'revisions' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tri

我的模型url模式如下所示:

url(r'^models/(?P<pk>\d+)/$', views.ThreediModelView.as_view(), 
    name='models'),
回溯

NoReverseMatch at /models/models/9999/
Reverse for 'revisions' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'models\\/revisions/(?P<pk>\\d+)/$']
Request Method: GET
Request URL:    http://localhost:9010/models/models/9999/
Django Version: 1.6.5
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'revisions' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'models\\/revisions/(?P<pk>\\d+)/$']
Exception Location: /home/vagrant/.buildout/eggs/Django-1.6.5-py2.7.egg/django/core/urlresolvers.py in _reverse_with_prefix, line 452
Python Executable:  /usr/bin/python
Python Version: 2.7.3
NoReverseMatch at/models/models/9999/
找不到参数为“(“”,)”且关键字参数为“{}”的“修订版”的反转。尝试了1种模式:[u'models\\/revisions/(?P\\d+/$”]
请求方法:获取
请求URL:http://localhost:9010/models/models/9999/
Django版本:1.6.5
异常类型:NoReverseMatch
异常值:
找不到参数为“(“”,)”且关键字参数为“{}”的“修订版”的反转。尝试了1种模式:[u'models\\/revisions/(?P\\d+/$”]
异常位置:/home/vagrant/.buildout/eggs/Django-1.6.5-py2.7.egg/Django/core/urlresolvers.py in_reverse_,带前缀,第452行
Python可执行文件:/usr/bin/Python
Python版本:2.7.3

请显示视图和完整回溯。url是否应该包含“/models/models/”?可能您在模板上生成的url不正确。查找url模板标记。@Alasdair更新了我的问题这里显然还有很多信息缺失。例如,错误消息清楚地告诉我们它找不到
修订版
URL,并且您没有告诉我们您在模板中使用该URL的位置或在URL.py中使用该URL的定义。绝对正确。问题出在模板中。有相当多的url模板标记。
NoReverseMatch at /models/models/9999/
Reverse for 'revisions' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'models\\/revisions/(?P<pk>\\d+)/$']
Request Method: GET
Request URL:    http://localhost:9010/models/models/9999/
Django Version: 1.6.5
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'revisions' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'models\\/revisions/(?P<pk>\\d+)/$']
Exception Location: /home/vagrant/.buildout/eggs/Django-1.6.5-py2.7.egg/django/core/urlresolvers.py in _reverse_with_prefix, line 452
Python Executable:  /usr/bin/python
Python Version: 2.7.3