我正在遵循 Django 注册的入门指南,当我访问时出现以下错误http://localhost:8080/accounts/register/
:
NoReverseMatch at /accounts/register/
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://localhost:8080/accounts/register/
Django Version: 1.5.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
Exception Location: /Library/Python/2.7/site-packages/django/template/defaulttags.py in render, line 424
Python Executable: /usr/bin/python
Python Version: 2.7.1
Python Path:
['/Users/Studio/Desktop/orro/t1/tut',
'/Library/Python/2.7/site-packages/setuptools-0.9.8-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Server time: Mon, 12 Aug 2013 18:53:54 -0500
Error during template rendering
In template /Users/Studio/Desktop/pod/t1/tut/tut/templates/base.html, error at line 16
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
8 <head>
9 <link rel="stylesheet" href="/style.css" />
10 <title>{% block title %}User test{% endblock %}</title>
11 </head>
12
13 <body>
14 <div id="header">
15 {% block header %}
16 <a href="{% url 'index' %}">{% trans "Home" %}</a> |
17
18 {% if user.is_authenticated %}
19 {% trans "Logged in" %}: {{ user.username }}
20 (<a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a> |
21 <a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>)
22 {% else %}
23 <a href="{% url 'auth_login' %}">{% trans "Log in" %}</a>
24 {% endif %}
25 <hr />
26 {% endblock %}
我的 urls.py:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'tut.views.home', name='home'),
# url(r'^tut/', include('tut.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
(r'^accounts/', include('registration.backends.default.urls', namespace='registration')),
)
有任何想法吗?