Python 未找到参数为 '()' 和关键字参数为 '{}' 的 'index' 反转。尝试了 0 个模式:[]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20993598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
提问by Charles Haro
I'm trying to get django-register to work on my website but I keep getting this error which I do not understand
我正在尝试让 django-register 在我的网站上工作,但我不断收到我不明白的错误
I'm using django 1.6 on Python 3.3
我在 Python 3.3 上使用 django 1.6
NoReverseMatch at /accounts/register/
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.6.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: D:\Programming\Py33\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 429
Python Executable: D:\Programming\Py33\python.exe
Python Version: 3.3.3
Python Path:
['D:\Programming\GItHub\photobyte\PhotoByte',
'D:\Programming\Py33\lib\site-packages\setuptools-2.0.3dev-py3.3.egg',
'C:\WINDOWS\SYSTEM32\python33.zip',
'D:\Programming\Py33\DLLs',
'D:\Programming\Py33\lib',
'D:\Programming\Py33',
'D:\Programming\Py33\lib\site-packages']
Server time: Wed, 8 Jan 2014 02:49:17 -0800
Error during template rendering
this is the html code that is erroring
这是出错的html代码
Its complaining about line 14
它抱怨第 14 行
In template D:\Programming\GItHub\photobyte\PhotoByte\templates\base.html, error at line 14
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
6 <head>
7 <link rel="stylesheet" href="/style.css" />
8 <title>{% block title %}User test{% endblock %}</title>
9 </head>
10
11 <body>
12 <div id="header">
13 {% block header %}
14 <a href="{% url 'index' %}">{% trans "Home" %}</a> |
15
16 {% if user.is_authenticated %}
17 {% trans "Logged in" %}: {{ user.username }}
18 (<a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a> |
19 <a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>)
20 {% else %}
21 <a href="{% url 'auth_login' %}">{% trans "Log in" %}</a>
22 {% endif %}
23 <hr />
24 {% endblock %}
This is my Urls.py for my project
这是我的项目的 Urls.py
urlpatterns = patterns('',
(r'^ImageUpload/', include('ImageUpload.urls')),
(r'^accounts/', include('registration.backends.default.urls')),
(r'^$', RedirectView.as_view(url='/ImageUpload/list/')), # Just for ease of use.
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Can someone explain what the error means please?
有人可以解释错误的含义吗?
采纳答案by praveen
Its complaining about line no.14 because Django is unable to determine the url named as "index" in your urls.py files. I don't see a URL named as "index" above. Where/What is the URL pattern for your home page?
它抱怨第 14 行,因为 Django 无法确定 urls.py 文件中名为“index”的 url。我没有看到上面名为“index”的 URL。您主页的 URL 模式在哪里/什么是?
回答by Charlie
This happens when the URL match expression has a parameter but there are none passed in with the reverse in the template.
当 URL 匹配表达式有一个参数但模板中没有反向传递时,就会发生这种情况。

