2014-01-08 28 views
13

我試圖讓Django的註冊在我的網站工作,但我不斷收到這個錯誤,我不明白未找到參數'()'和關鍵字參數'{}'的'index'反向。 0模式(S)嘗試:[]

我使用Django 1.6 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 

這是示數

其抱怨行HTML代碼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 %} 

這是我Urls.py我p roject

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) 

有人可以解釋一下錯誤的含義嗎?

回答

15

它抱怨第14行,因爲Django無法確定您的urls.py文件中名爲「index」的url。我沒有看到上面名爲「index」的URL。主頁的URL /模式在哪裏/什麼是?

+0

我對django的工作原理相當陌生。我認爲它會包含在django-registration.backends.defualt.urls中。目前我沒有主頁。所以,如果我添加了一個名稱索引的url,它會重定向到那個? –

+1

耶! ('',(r'^ home /「,home,name =」home「), (r'^ ImageUpload /',include('ImageUpload.urls')), (r' accounts',include('registration.backends.default.urls')), (r'^ $',RedirectView.as_view(url ='/ ImageUpload/list /')),#僅用於簡單易用 )+靜態(settings.MEDIA_URL,document_root = settings.MEDIA_ROOT) – praveen

+0

你先生很棒。謝謝你解釋:) –

3

發生這種情況時,URL匹配表達式有一個參數,但沒有傳入與模板中的相反。

相關問題