首页 > 解决方案 > 自定义 django-allauth password_reset_from_key 模板

问题描述

我正在使用 django 2.2.3,我正在覆盖 django-allauth 模板,在 password_reset_from_key 模板上我遇到了 NoReverseMatch 异常,

Reverse for 'account_reset_password_from_key' with no arguments not found. 1 pattern(s) tried: ['accounts/password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$']

因此它需要参数,并且可能该参数是重置密码期间生成的密钥。从 URL 模式中,'key' 是变量的名称

我试图用'key'传递它。

<form method="POST" action="{% url 'account_reset_password_from_key' key %}">
...
</form>

但它没有用。怎么了?

标签: pythondjangodjango-allauth

解决方案


如果您没有覆盖 allauth 视图,请使用action_url

<form method="POST" action="{{ action_url }}">

这就是视图传递给模板的内容。


推荐阅读