2

我正在努力实现这里建议的代码:

但是有了这段代码:

from django.conf.urls.defaults import include
from django.conf.urls.defaults import patterns
from django.conf import settings
from django.contrib.auth.views import password_change
from django.contrib import admin
from django_pci_auth.views import index
from django_pci_auth.forms import ValidatingPasswordChangeForm
import django.contrib.admindocs.urls

admin.autodiscover()

urlpatterns = patterns(
    '',  # prefix
    (r'^admin/', include(admin.site.urls)),
    (r'^admin/doc/', include(django.contrib.admindocs.urls)),
    (r'^change_password/$', password_change,
        {'password_change_form': ValidatingPasswordChangeForm}),
    (r'', index),
)

if settings.DEBUG:
    urlpatterns += patterns(
        '',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT}),
    )

我得到:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/change_password/

Django Version: 1.4.2
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  69.             return view(request, *args, **kwargs)
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/contrib/auth/views.py" in password_change
  244.         post_change_redirect = reverse('django.contrib.auth.views.password_change_done')
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
  476.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/Users/aclark/Developer/django-pci-auth/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
  396.                 "arguments '%s' not found." % (lookup_view_s, args, kwargs))

Exception Type: NoReverseMatch at /change_password/
Exception Value: Reverse for 'django.contrib.auth.views.password_change_done' with arguments '()' and keyword arguments '{}' not found.

代码在这里:https ://github.com/aclark4life/django-pci-auth

4

1 回答 1

1

您需要更改密码的 url...这里是设置您想要使用完整 urls.py 做什么的好指南。

于 2012-10-24T19:02:33.253 回答