忘了密码功能,django

时间:2011-08-03 14:26:42

标签: django passwords reset

我按照这里的代码: http://drumcoder.co.uk/blog/2010/apr/09/django-reset-password/ 以及这里: http://shrenikp.webs.com/apps/blog/entries/show/7133721-implement-forgot-password-on-customer-ui- 和这里: http://blog.montylounge.com/2009/07/12/django-forgot-password/

这是我目前希望使用的代码以及我目前使用的代码

[base.html文件]

            <form name="login_form" action="/login/" method="post" accept-charset="utf-8" style="display: inline">
                {% csrf_token %}
                Username: <input type="text" name="username" value="" /><br />
                Password: <input type="password" name="password" value="" /><br />
                <input type="submit" value="submit" value = "" id ="submit" />
                <p><a href="{% url password_reset %}">Forgot password?</a></p>
            </form>

[url.py]

urlpatterns = patterns('',
    url(r'^password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'),
    (r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
    (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
    (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
)

我收到类似这样的错误:

unknown specifier: ?P[
由于某种原因

此行错误...(r'^ reset /(?P [0-9A-Za-z] +) - (?P。+)/ $' 有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

您需要将其更改为:

(r'^reset/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$', 'django.contrib.auth.views.password_reset_confirm')

您需要在模板中{% csrf_token %}标记后添加标记<form>。试试吧。