2013-08-12 1 views
0

Я следующий руководство по началу работы для регистрации Джанго и я получаю следующее сообщение об ошибке, когда я посещаю http://localhost:8080/accounts/register/:NoReverseMatch в/счетов/регистрация/

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')), 


) 

Любые идеи?

ответ

2

Нужная информация находится в TRACEBACK вы предоставили,

В шаблоне /Users/Studio/Desktop/pod/t1/tut/tut/templates/base.html, ошибка в строке 16 Обратный для 'index' с аргументами '()' и аргументами ключевого слова '{}' не найден.

В вашем шаблоне base.html в строке 16 вы используете тег url для ссылки на представление с именем 'index'.

16  <a href="{% url 'index' %}">{% trans "Home" %}</a> | 

Однако, нет никакого образца URL по имени index в ваших шаблонах URL. Поэтому обратное не удается, и возникает исключение NoReverseMatch.

Вы можете исправить это, создав индексный указатель в вашем модуле tut.views и добавив его к вашим шаблонам URL.

url(r'^$', 'tut.views.index', name='index'), 

В качестве альтернативы, вы можете удалить {% url 'index' %} из шаблона, пока вы не добавите индексный просмотр.