我安装了名为注册的 Django 应用程序。我设置了模板,添加到 url 和查看文件,一切都很正常。现在我在注销后重新登录系统时遇到了问题(以前从未发生过)我从浏览器中清除了 cookie 和浏览历史记录(我尝试了多个以查看是否是问题所在)并进入“/registration/login /" 然后我输入信息就可以登录了。我单击注销按钮,它会将我注销,一切正常。问题是当我第二次登录时,我转到“/registration/login/”并在表单中输入我的信息并提交并获取
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) ...
现在通常这些错误会在“Reverse for '' with”中给出一个名称以及一个行号,它通常是一个 URL 问题。我不明白的是,如果我可以访问此 URL,为什么表单不会发布到它。提前感谢您提供的任何提示或提示,让我知道您需要查看的内容,我会上传。
登录模板文件 {% extends '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 }} 但它没有改变任何东西我仍然遇到相同的错误
URL 模式文件:
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'),
)