如何覆盖默认的django忘记密码模板?

时间:2013-04-19 04:51:08

标签: django templates django-templates forgot-password

密码重置模板存储在:

/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/registration

但是,我想覆盖我的Django提供的默认模板。我不想直接转到该目录并编辑模板。因此,我在templates/registration目录中创建了具有相同名称的密码重置模板。但是,我仍然得到相同的inbuild django模板。我的一个模板password_reset_form.html如下所示:

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8">

<title>ATS | Password Reset Form</title>



<!--google web font-->
<link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic,700|Lato:700,300,400' rel='stylesheet' type='text/css'>

<!--style sheets-->
<link rel="stylesheet" media="screen" href="{{ STATIC_URL }}bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" media="screen" href="{{ STATIC_URL }}bootstrap/css/style.css"/>
<link rel="stylesheet" media="screen" href="{{ STATIC_URL }}bootstrap/css/static.css"/>
<style>
li
{
list-style-type: none;
padding: 0px;
margin: 0px;
}
#footer {
margin-top: 40px;
}

</style>
<!--jquery libraries / others are at the bottom-->
<script src="{{ STATIC_URL }}bootstrap/js/jquery-1.7.1.min.js" type="text/javascript"></script>
</head>
<body>
<!-- Header starts
================================================== -->
<header id="header">
  <div class="container">
    <div class="row"> 

      <!--logo starts-->
      <div class="span4"> <a href="/login/"><img src="{{ STATIC_URL }}bootstrap/img/auto.png"></a> </div>
      <!--logo ends--> 


  </div>
</header>
<div class="container">
<h2 class="lead text-center">Password Reset</h2><br /> <br />



<form action="" class="well span10" method="post">
{% csrf_token %}
{% block content %}
<p class="text-info text-center"><strong>Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one.</strong></p>
<span class="text-error text-center"><strong> {{ form.email.errors }}</strong></span><br/>
<p class="text-center"><label for="id_email">Enter your E-mail address:</label> {{ form.email }}</p> 
<p class="text-center"><button class="btn btn-success">Reset my Password</button></p>
</form>
{% endblock %}
</div>
<footer id="footer">
  <div class="container">
    <div class="row"> 

      <!--small intro and copyright starts-->
      <div class="span7">
        <a data-toggle="tab" href="/how_it_works/">How it works? &nbsp; &nbsp;</a> 
        <a data-toggle="tab" href="/how_it_works/">Terms and Conditions &nbsp; &nbsp;</a> 
        <a data-toggle="tab" href="/how_it_works/">How to use? </a> <br /><br />
        <p class="copyright"> ©2013 Automatic Text Summarization(ATS) </p>
      </div>

模板中是否有遗漏的东西?

1 个答案:

答案 0 :(得分:5)

您是否已将模板放在apps目录中?如果是,请在django.contrib.admin设置中INSTALLED_APP之前指定您的应用。

如果您已将模板放在其他文件夹中,请确认已在TEMPLATE_DIRS中正确添加了目录,并且文件系统加载程序中的目录位于TEMPLATE_LOADERS中的_app_directories _loader之前。< / p>

所以它应该是

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    )

Template loaders

的更多参考资料