Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

此生再无相见时 提交于 2019-12-20 18:09:15

问题


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?


回答1:


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?




回答2:


This happens when the URL match expression has a parameter but there are none passed in with the reverse in the template.



来源:https://stackoverflow.com/questions/20993598/reverse-for-index-with-arguments-and-keyword-arguments-not-found-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!