NoReverseMatch at / accounts / password / reset / django registration redux

时间:2018-02-07 21:41:25

标签: python django

我正在尝试在我的项目中使用django-registration-redux进行身份验证,但在测试密码重置时,我想出了包含以下追溯的错误

Internal Server Error: /accounts/password/reset/
Traceback (most recent call last):
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 418, in dispatch
    return super(PasswordResetView, self).dispatch(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/edit.py", line 183, in post
    return self.form_valid(form)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 431, in form_valid
    form.save(**opts)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 289, in save
    email, html_email_template_name=html_email_template_name,
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 236, in send_mail
    body = loader.render_to_string(email_template_name, context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader.py", line 68, in render_to_string
    return template.render(context, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 207, in render
    return self._render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 40, in render
    output = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader_tags.py", line 63, in render
    result = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 458, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
    raise NoReverseMatch(msg)
NoReverseMatch: Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name.
[07/Feb/2018 22:33:51] "POST /accounts/password/reset/ HTTP/1.1" 500 197836
[2018-02-07 22:33:51,527] - Broken pipe from ('127.0.0.1', 45428)

Internal Server Error: /accounts/password/reset/
Traceback (most recent call last):
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 418, in dispatch
    return super(PasswordResetView, self).dispatch(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/edit.py", line 183, in post
    return self.form_valid(form)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 431, in form_valid
    form.save(**opts)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 289, in save
    email, html_email_template_name=html_email_template_name,
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 236, in send_mail
    body = loader.render_to_string(email_template_name, context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader.py", line 68, in render_to_string
    return template.render(context, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 207, in render
    return self._render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 40, in render
    output = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader_tags.py", line 63, in render
    result = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 458, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
    raise NoReverseMatch(msg)
NoReverseMatch: Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name.
[07/Feb/2018 22:33:52] "POST /accounts/password/reset/ HTTP/1.1" 500 197836

我的注册,登录和其他django-registration功能正在运行,但这仍然会出错。我检查了其他与SO相关的问题,但到目前为止,他们都没有帮助我。下面是我的项目的urls.py

from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import url, include
from django.contrib import admin
from sweet import views

urlpatterns = [
    url(r'^accounts/', include('registration.backends.default.urls')),
    # url(r'^lollipop/', include('lollipop.urls')),
    # url(r'^pinpop/', include('pinpop.urls')),
    url(r'^', include('sweet.urls')),   
    # url(r'^', views.index, name='index'),
    url(r'^admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

编辑: 按照BUZZY的回答,这是新的追溯

Traceback (most recent call last):
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 418, in dispatch
    return super(PasswordResetView, self).dispatch(*args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/views/generic/edit.py", line 183, in post
    return self.form_valid(form)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/views.py", line 431, in form_valid
    form.save(**opts)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 289, in save
    email, html_email_template_name=html_email_template_name,
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 236, in send_mail
    body = loader.render_to_string(email_template_name, context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader.py", line 68, in render_to_string
    return template.render(context, request)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 207, in render
    return self._render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 40, in render
    output = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/loader_tags.py", line 63, in render
    result = self.nodelist.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/template/defaulttags.py", line 458, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/home/agozie/anaconda3/envs/env1/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
    raise NoReverseMatch(msg)
NoReverseMatch: Reverse for 'password_reset_confirm' with keyword arguments '{u'uidb36': 'MjY', u'token': u'4ti-05f34bb12daa049f844d'}' not found. 1 pattern(s) tried: ['reset/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$']
[07/Feb/2018 22:57:25] "POST /accounts/password/reset/ HTTP/1.1" 500 201717.

仍然无法正常工作

1 个答案:

答案 0 :(得分:1)

看起来找不到名为password_reset_confirm的视图。

它位于auth应用中,请尝试添加:

url(r'^', include('django.contrib.auth.urls'))

到您的网址。