对于'index'与参数'()'和关键字参数'{}'未找到相反。 0模式尝试:[] [英] Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
本文介绍了对于'index'与参数'()'和关键字参数'{}'未找到相反。 0模式尝试:[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用django 1.6 Python 3.3
NoReverseMatch at / accounts / register /
使用参数'()'和关键字参数'{}'未找到。 0模式尝试:[]
请求方法:GET
请求URL:http://127.0.0.1:8000/accounts/register/
Django版本:1.6.1
异常类型:NoReverseMatch
异常值:
反向'索引',参数'()'和关键字参数'{}'未找到。 0模式尝试:[]
异常位置:D:\Programming\Py33\lib\site-packages\django\core\urlresolvers.py在_reverse_with_prefix中,第429行
Python可执行文件:D:\Programming\Py33\python.exe
Python版本:3.3.3
Python路径:
['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-包''
服务器时间:Wed,8 Jan 2014 02:49 :17 -0800
模板渲染时出错
这是错误的HTML代码
它的抱怨第14行
在模板D中:\Programming\GItHub\photobyte\PhotoByte\templates\base .html,第14行的错误
反向'索引',参数'()'和关键字参数'{}'未找到。 0模式尝试:[]
4< html xmlns =http://www.w3.org/1999/xhtmlxml:lang =enlang =en>
5
6< head>
7< link rel =stylesheethref =/ style.css/>
8< title> {%block title%}用户测试{%endblock%}< / title>
9< / head>
10
11< body>
12< div id =header>
13 {%block header%}
14< a href ={%url'index'%}> {%transHome%}< / a> |
15
16 {%if user.is_authenticated%}
17 {%trans登录%}:{{user.username}}
18(< a href ={%url'auth_logout'%}> {%trans注销%}< / a> |
19< a href ={%url'auth_password_change'%}> {%trans更改密码%}< / a>)
20 {%else%}
21< a href ={%url'auth_login'%}> {% 登录%}< / a>
22 {%endif%}
23< hr />
24 {%endblock%}
这是我的项目的Urls.py
urlpatterns = patterns('',
(r'^ ImageUpload /',include('ImageUpload.urls')) ,
(r'^ accounts /',include('registration.backends.default.urls')),
(r'^ $',RedirectView.as_view(url ='/ ImageUpload / list / ')),#只是为了方便使用
)+ static(settings.MEDIA_URL,document_root = settings.MEDIA_ROOT)
有人可以解释错误是什么意思吗?
解决方案
它抱怨第14行,因为Django无法确定urls.py中名为index的网址文件。我没有看到一个名为index的URL。哪里/您的主页的URL模式是什么?
I'm trying to get django-register to work on my website but I keep getting this error which I do not understand
I'm using django 1.6 on Python 3.3
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
Its complaining about line 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
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?
解决方案
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?
这篇关于对于'index'与参数'()'和关键字参数'{}'未找到相反。 0模式尝试:[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文