0

Stumped as to why my template isn't showing my custom password reset form.

Here is code:

forms.py

class CustomPasswordResetForm(PasswordResetForm):
def __init__(self, *args, **kwargs):
    super(CustomPasswordResetForm, self).__init__(*args, **kwargs)

email = forms.EmailField(
    label='', widget=forms.EmailInput(attrs={
        'placeholder': 'placetest@test.com',
        'class': 'form-field', }))

Views.py

class PasswordResetView(auth_views.PasswordResetView):
form_class = CustomPasswordResetForm
template_name = 'password_reset.html'

urls.py

urlpatterns = [
path('login/', LoginView.as_view(), name='login'),
path('password_reset', PasswordResetView.as_view(), name='password_reset'),
path('login_success/', login_success, name='login_success'),]

Template

{% load static %}
{% block title %}Home{% endblock %}
{% block content %}

<div class="form-container" id="pwrest">
    <div class="form-title">
        <h2>Enter your email address</h2>
    </div>

    <form method="POST">
        {% csrf_token %}
        <p>email</p>
        <div>{{ form.email }}</div>
        <input class="submit-button" type="submit" value="Send me instructions!">
    </form>

</div>

</div>


{% endblock %}

CSS

.form-field{
    width: 300px;
    height:30px;
    margin-bottom:5px;
    margin-top:5px;
    border:none;
    border-radius: 5px;
    background-color:whitesmoke;
}

Rendered HTML

    <div class="form-title">
        <h2>Enter your email address</h2>
    </div>

    <form method="POST">
        <input type="hidden" name="csrfmiddlewaretoken" value="TOKEN">
        <p>email</p>
        <div><input type="email" name="email" autocomplete="email" maxlength="254" required id="id_email"></div>
        <input class="submit-button" type="submit" value="Send me instructions!">
    </form>

</div>

</div>

When I view the template in my browser, I am seeing the form field as the default, its almost like its just not recognizing the CSS class.

I'm not sure what I've missed.

.

0 Answers0