password reset pages are not showing customizing html file

366 views
Skip to first unread message

Ali Ahammad

unread,
May 13, 2020, 1:45:02 PM5/13/20
to Django users
hello everyone

i am trying to make a blog where i am trying to customize password reset forms. 
here is my bloggapp/urls.py:
from django.contrib import admin
from django.urls import path, include 
from django.views.generic.base import TemplateView 
from django.contrib.auth import views as auth_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('accounts/', include('accounts.urls')), 
    #path('users/', include('django.contrib.auth.urls')), 
    path('accounts/login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
    path('accounts/logout/', auth_views.LogoutView.as_view(template_name='logout.html'), name='logout'),
    path('', include('blog.urls')),
    path('password-reset/'
         auth_views.PasswordResetView.as_view
         (template_name='registration/password_reset.html'), 
         name='password_reset'),
    path('password-reset/done/'
         auth_views.PasswordResetDoneView.as_view
         (template_name='registration/password_reset_done.html'), 
         name='password_reset_done'),
    path('password-reset-confirm/<uidb64>/<token>/',
         auth_views.PasswordResetConfirmView.as_view(
             template_name='registration/password_reset_confirm.html'
         ),
         name='password_reset_confirm'),
     path('password-reset-complete/',
         auth_views.PasswordResetCompleteView.as_view(
             template_name='registration/password_reset_complete.html'
         ),
         name='password_reset_complete'),

]

http://localhost:8000/password-reset/ this page is showing the html form i have wrote in registration/password_reset.html directory which is under accounts app. in the accounts app there is templates folder and in this folder i have kept base.html. in the same folder i have created registration folder where i kept login.html and password_reset.html.

i have set up my email smtp in sendgrid and it is working. besides registration/login.html,templates/signup.html files are working.
i am including my base.html file also:

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,
initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/\
bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81i\
uXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <title>{% block title %}Newspaper App{% endblock title %}</title>
</head>

<body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark mb-4">
        <a class="navbar-brand" href="{% url 'home' %}">Newspaper</a><button class="navbar-toggler" type="button"
            data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false"
            aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarCollapse">
            {% if user.is_authenticated %}
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown"
                        aria-haspopup="true" aria-expanded="false">
                        {{ user.username }}
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userMenu">
                        <a class="dropdown-item" href="{% url 'password_reset'%}">Change password</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'logout' %}">
                            Log Out</a>
                    </div>
                </li>
            </ul>
            {% else %}
            <form class="form-inline ml-auto">
                <a href="{% url 'login' %}" class="btn btn-outline-secondary">
                    Log In</a>
                <a href="{% url 'signup' %}" class="btn btn-primary ml-2">
                    Sign up</a>
            </form>
            {% endif %}
        </div>
    </nav>
    <div class="container">
        {% block content %}
        {% endblock content %}
    </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4\
YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
1.14.3/
umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbB\
JiSnjAK/
l8WvCWPIPm49" crossorigin="anonymous"></script>
js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ\
6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>

</html>

and templates/home.html also:
{% extends 'base.html' %}
{% block title %}Home{% endblock title %}
{% block content %}
{% if user.is_authenticated %}
Hi {{ user.username }}!
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %}
<p>You are not logged in</p>
<a href="{% url 'login' %}">Log In</a> |
<a href="{% url 'signup' %}">Sign Up</a>
{% endif %}
{% endblock content %}


but the below mentioned html files are not showing in the browser but they are coming as django administration view.



<!-- templates/registration/password_reset_complete.html -->
{% extends 'base.html' %}
{% block title %}Password reset complete{% endblock title %}
{% block content %}
<h1>Password reset complete</h1>
<p>Your new password has been set. You can log in now on the
<a href=
"{% url 'login' %}">log in page</a>.</p>
{% endblock content %}

<!-- templates/registration/password_reset_confirm.html -->
{% extends "base.html" %}
 {% load crispy_forms_tags %} 
{% block content %}
    <div class="content-section">
        <form method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4">Reset Password</legend>
                {{ form|crispy }}
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Reset Password</button>
            </div>
        </form>
    </div>
{% endblock content %}

<!-- templates/registration/password_reset_done.html -->
{% extends "base.html" %}
{% block content %}
    <div class="alert alert-info">
        Your password has been set.
    </div>
    <a href="{% url 'login' %}">Sign In Here</a>
{% endblock content %}


i don't what i have made wrong. will you please point me in the right direction? i really need this.

Ali Ahammad

unread,
May 14, 2020, 9:47:08 AM5/14/20
to Django users
hello guys 

i have tried email_template_name = 'registration/password_reset_email.html', success_url = reverse_lazy('registration:password_reset_done') but still no luck. i tried to edit template_name='accounts/reset_password.html, seems like django is reaching out to this hml file. but when i delete all the code or kept all the code inside reset_password.html, it won't have any effect. seems like whtever i write it isn't rendering to base.html. what should be the effective solution?  

please help
Reply all
Reply to author
Forward
0 new messages