2013-10-08 59 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文件没有捕获根目录的请求,但这没有意义,因为我可能会击中根网址并被送达一页。我决定浏览设置页面,我发现该行改变了它,我们恢复了正常。