2013-10-08 107 views
0

我安裝了稱爲註冊的Django應用程序。我設置了模板,添加到網址和查看文件,一切工作只是丹迪。現在我有一個問題重新登錄到系統後,我註銷(這從來沒有發生過)我清除瀏覽器中的cookies和瀏覽歷史記錄(我嘗試了多個,看看是否是問題),並得到「/註冊/登錄/「,然後輸入信息並登錄。我點擊我的註銷按鈕,它會記錄我所有的事情。問題是,當我去登錄第二次我去「/註冊/登錄/」,然後輸入我的信息轉換成表格並提交,並得到Django NoReverseMatch註冊應用程序

NoReverseMatch at /registration/login/ 
Reverse for '' with arguments '()' and keyword arguments '{}' not found. 
Request Method: POST 
Request URL: http://genie:8181/registration/login/ 
Django Version: 1.5.2 
Exception Type: NoReverseMatch 
Exception Value:  
Reverse for '' with arguments '()' and keyword arguments '{}' not found. 
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py  in _reverse_with_prefix, line 416 
Python Executable: /usr/bin/python 
Python Version: 2.7.3 
Python Path:  
['/var/www/RegCal', 
'/usr/local/lib/python2.7/dist-packages/South-0.8.2-py2.7.egg', 
'/usr/local/lib/python2.7/dist-packages/distribute-0.7.3-py2.7.egg', 
'/usr/local/lib/python2.7/dist-packages/setuptools-1.1.6-py2.7.egg', 
'/usr/lib/python2.7', 
'/usr/lib/python2.7/plat-linux2', 
'/usr/lib/python2.7/lib-tk', 
'/usr/lib/python2.7/lib-old', 
'/usr/lib/python2.7/lib-dynload', 
'/usr/local/lib/python2.7/dist-packages', 
'/usr/lib/python2.7/dist-packages'] 
Server time: Tue, 8 Oct 2013 17:18:11 -0500 
Traceback Switch to copy-and-paste view 

/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response 
        response = callback(request, *callback_args, **callback_kwargs) ... 
▶ Local vars 
/usr/local/lib/python2.7/dist-packages/django/views/decorators/debug.py in  sensitive_post_parameters_wrapper 
      return view(request, *args, **kwargs) ... 

現在通常這些錯誤會給在一個名字「反向」與「以及一個行號,通常是URL問題。我不明白的是,如果我可以訪問這個URL,爲什麼表單不會發布到它。在此先感謝您提供任何提示或提示,讓我知道您需要查看的內容,然後我將其上傳。對於登錄

模板文件{%「延伸base.html文件」%}

{% block title %} | Please login{% endblock title %} 

{% block content %} 
    {% if forms.errors %} 
     <p>Sorry, that's not a valid username or password</p> 
    {% endif %} 
    <div class="row-fluid"> 
     <form id="login_small" class="span6" action="{{ app_path }}" method="post" >{% csrf_token %} 
      <div class="span4 pic"></div> 

      <div class="span8"> 
       <span></span> 
       <input type="text" name="username" value="Username" id="username"> 
       <input type="password" name="password" value="password" id="password"> 
       <input type="submit" value="login" class="submit_but" /> 
      </div> 
     </form> 
    </div> 

{% endblock content %} 

只是,我試圖改變一個音符{{APP_PATH}},但它並沒有改變什麼,我還是得到了同樣的錯誤

網址格式文件:

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('', 
    #Get urls from the userprofile app 
    url(r'^account/', include('userprofile.urls')), 

    #URL Patterns for the registration apps 
    url(r'^registration/', include('registration.backends.default.urls')), 

    #Site Admin URL Patterns 
    url(r'^admin/', include(admin.site.urls)), 
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 

    #Day URL Patterns 
    url(r'^view/day/(\d+)/(\d+)/(\d+)/$', 'courseCalendar.views.day'), 
    url(r'^view/day$', 'courseCalendar.views.day'), 

    #Month URL Patterns 
    url(r'^view/month$', 'courseCalendar.views.month'), 
    url(r'^view/month/(?P<year>\d{4})/(?P<month>\d{1,2})$', 'courseCalendar.views.month'), 
    url(r'^view/month/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<change>\w+)$', 'courseCalendar.views.month'), 

    #Year URL Patterns 
    url(r"^view/year/(?P<year>\d+)$", 'courseCalendar.views.year'), 

    #Course Edit Patterns 
    url(r"^edit/course/(?P<courseID>\d+)$", 'courseCalendar.views.courseEdit'), 
    url(r"^edit/course$", 'courseCalendar.views.courseEdit'), 

    #Enroll Student Page 
    url(r"^enroll/(?P<courseID>\d+)/(?P<userID>\d+)$", 'courseCalendar.views.enroll'), 

    #Search through existing courses 
    url(r"^search/$", 'courseCalendar.views.courseSearch'), 

    #Root Directory Pattern 
    url(r'', 'courseCalendar.views.year'), 
) 
+0

好吧,它似乎試圖扭轉一個空的序列因此'''',張貼您的模板 –

+0

我試着將其從app_path更改爲「/ registration/login /」,但它並沒有改變 – Cody

+1

你可以添加你的網址的.py? – yuvi

回答

0

嗯,我覺得這真是愚蠢。我得到這個錯誤的原因是因爲我有LOGIN_REDIRECT_URL =''。我想通過輸入不同的參數到允許我登錄的URL的下一個參數來解決問題。起初我以爲這是我的url文件沒有捕獲根目錄的請求,但這沒有意義,因爲我可能會擊中根網址並被送達一頁。我決定瀏覽設置頁面,我發現該行改變了它,我們恢復了正常。