如何覆盖所有Auth内置模板Django

时间:2020-02-26 10:53:12

标签: python django django-templates django-allauth

我正在使用Django all auth来实现密码重置功能,但是我想自定义密码重置模板,以下是我的网址:

urls.py

from django.conf.urls import url,include
from django.urls import path
from rest_framework_jwt.views import obtain_jwt_token,refresh_jwt_token
from . import views


# Registration,Login,Forgot,Profile change

urlpatterns=[

    url(r'^accounts/', include('allauth.urls')),

]

当我点击此网址时-> http://127.0.0.1:8000/ThiefApp/accounts/password/reset/

我没有使用模板

enter image description here

如何自定义上述模板或如何使用其他模板?有什么建议吗?

1 个答案:

答案 0 :(得分:1)

allauth在allauth / templates目录中包含许多模板。如果要覆盖任何模板,则需要在项目中添加与allauth模板目录包含的名称相同的模板。(参考:https://django-allauth.readthedocs.io/en/latest/templates.html#overridable-templates)。

在这里您要覆盖密码重置页面,然后在项目中创建“ password_reset.html” 模板。您的模板目录结构必须类似于yourproject/templates/allauth/account/。希望对您有所帮助:)

相关问题