urls.py
app_name='user'
urlpatterns = [
re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',auth_views.PasswordResetConfirmView.as_view(template_name='user/password_reset_confirm.html'), name='password_reset_confirm'),
]
模板
{{ protocol }}://{{ domain }}{% url 'user:password_reset_confirm' uidb64=uid token=token %}
显示以下错误:
Reverse for 'password_reset_confirm' with keyword arguments '{'uidb64': '', 'token': ''}' not found. 1 pattern(s) tried: ['user/reset/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$']
带有值
{{ protocol }}://{{ domain }}{% url 'user:password_reset_confirm' uidb64='hello' token='howareyou' %}
Reverse for 'password_reset_confirm' with keyword arguments '{'uidb64': 'hello', 'token': 'howareyou'}' not found. 1 pattern(s) tried: ['user/reset/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$']
答案 0 :(得分:0)
token=howareyou
将不匹配token
的正则表达式。
预期令牌的中间应带有连字符,例如:howare-you
。
答案 1 :(得分:0)
您可以使用
urlpatterns = [
path('reset/<uidb64>/<token>/', #rest of it),
]