模板password_reset_form.html没有覆盖Django管理界面的模板。

3

我希望重写django.contrib.auth.urls中的模板,其中包括accounts/password_reset/[name='password_reset']。但是我无法使用我的模板替换此URL的Django管理模板。根据文档,我的模板位于registration/password_reset_form.html,但不起作用。


1
欢迎来到Stack Overflow,为了让我们能够帮助您,您需要以特定于您的方式提出问题,并展示您已经尝试解决该问题。阅读 - Mike Tung
你好,谢谢。我发现我忘了详细说明问题,请见谅。我想重新编写django.contrib.auth.urls中存在的模板,其中包括accounts/password_reset/ [name = 'password_reset']。然而,我无法通过我的模板替换这个url的django admin模板。按照文档,我的模板位于registration/password_reset_form.html,但是没有起作用。 - H4rDN00b
2个回答

3

1

你是否在使用CBV(基于类的视图)?在views.py或urls.py中设置template_name

例如:

path('question_directory/', views.UpdateDirectry.as_view(template_name='accounts/profile_form.html'), name='question_directory')

或者

class UpdateDirectry(generic.edit.FormView):
    model = Question
    template_name = 'accounts/editable_directory.html'

你好,谢谢。我发现我忘了详细说明问题,抱歉。以下是问题:我想重写django.contrib.auth.urls中存在的模板,其中包括accounts/password_reset/[name='password_reset']。然而,我无法将django管理模板替换为此URL的模板,我的模板在registration/password_reset_form.html中,正如文档所述,但不起作用。 - H4rDN00b
我建议您创建另一个问题,并将代码复制粘贴到那里,因为问题仍然不清楚。 - Amin.B

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接