如何自定义password_reset_confirm.html

时间:2018-03-20 19:36:09

标签: django

我在我的Django项目的password_reset_confirm.html目录中放了一个名为templates/registration/的文件。但是,如果我更改extends标记,它将不会加载任何其他内容。当用户从其电子邮件收件箱中单击密码重置链接时,将加载此模板。

这是password_reset_confirm.html的样子:

{% extends "admin/base_site.html" %}
{% load i18n %}

{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; {% trans 'Password reset confirmation' %}
</div>
{% endblock %}

{% block title %}{{ title }}{% endblock %}
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
{% block content %}
    THIS IS A CUSTOM FILE; I ONLY ADDED THIS SENTENCE.
    {% if validlink %}
        <p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>

        <form method="post">{% csrf_token %}
        {{ form.new_password1.errors }}
        <p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{ form.new_password1 }}</p>
        {{ form.new_password2.errors }}
        <p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{ form.new_password2 }}</p>
        <p><input type="submit" value="{% trans 'Change my password' %}" /></p>
        </form>
    {% else %}
        <p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
    {% endif %}
{% endblock %}

我想将前两行更改为:

{% extends "base.html" %}
{% load i18n mezzanine_tags staticfiles %}

但是当我这样做时,那些线下面没有任何东西加载。我需要更改什么才能使模板加载我的base.html以及密码重置表单?

编辑:根据要求,这是我的base.html

<!doctype html>
<html lang="{{ LANGUAGE_CODE }}"{% if LANGUAGE_BIDI %} dir="rtl"{% endif %}>

{% load pages_tags mezzanine_tags i18n staticfiles %}

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="{% block meta_keywords %}{% endblock %}">
    <meta name="description" content="{% block meta_description %}{% endblock %}">
    <title>{% block meta_title %}{% endblock %}{% if settings.SITE_TITLE %} | {{ settings.SITE_TITLE }}{% endif %}</title>
    <link rel="shortcut icon" href="{% static "img/favicon.ico" %}">

    {% ifinstalled mezzanine.blog %}
        <link rel="alternate" type="application/rss+xml" title="RSS" href="{% url "blog_post_feed" "rss" %}">
        <link rel="alternate" type="application/atom+xml" title="Atom" href="{% url "blog_post_feed" "atom" %}">
    {% endifinstalled %}

    {% compress css %}
        <link rel="stylesheet" href="{% static "css/mezzanine.css" %}">
        {% ifinstalled cartridge.shop %}
            <link rel="stylesheet" href="{% static "css/cartridge.css" %}">
            {% if LANGUAGE_BIDI %}
                <link rel="stylesheet" href="{% static "css/cartridge.rtl.css" %}">
            {% endif %}
        {% endifinstalled %}

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
        <link rel="stylesheet" href="{% static "css/custom.css" %}">
        {% block extra_css %}{% endblock %}
    {% endcompress %}

    {% compress js %}
        <script src="https://js.stripe.com/v3/"></script>
        <script src="{% static "mezzanine/js/"|add:settings.JQUERY_FILENAME %}"></script>   
        <script
            src="http://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
            crossorigin="anonymous">
        </script>
        <script 
            src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
            integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
            crossorigin="anonymous">
        </script>
        {% block extra_js %}{% endblock %}
    {% endcompress %}

    <!--[if lt IE 9]>
        <script src="{% static "js/html5shiv.js" %}"></script>
        <script src="{% static "js/respond.min.js" %}"></script>
    <![endif]-->

    {% block extra_head %}{% endblock %}
</head>

<body id="{% block body_id %}body{% endblock %}">
    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container">
            <a class="navbar-brand" href="/">{{ settings.SITE_TITLE }}</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarResponsive">
                {% page_menu "menus/dropdown.html" %}
            </div>
        </div>
    </nav>

    <!-- Page Content -->
    {% block main %}
    {% endblock %}  
    <!-- /.container -->


    {% block footer_js %}
    {% include "includes/footer_scripts.html" %}
    {% endblock %}
</body>
</html>

0 个答案:

没有答案