I am new to python and Django framework and I created a login form which works well but only thing is that I am not able to mask the password while it's being entered.
Views.py
class LoginFormView(FormView):
template_name = 'Login/login-page.html'
form_class = AuthenticationForm
def form_valid(self, form):
login(self.request, form.get_user())
return redirect('personal:index')
Login/login-page.html
{% block content %}
<form class="form-horizontal" method="post" enctype="multipart/form-data">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{field.html_name}}</label>
<div class="col-sm-5">
<input class="form-control" id="{{ field.id_for_label }}" name="{{ field.html_name }}" />
</div>
</div>
{{ field.errors }}
{% endfor %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success ">
<span class="glyphicon glyphicon-log-in" aria-hidden="true"></span> Sign in
</button>
</div>
</div>
</form>
{% endblock %}
Whenever I try to add the following code in views.py
password = forms.CharField(widget=PasswordInput)
I has no effect and if I try the same with form_class instead of forms it doesnt work as type object 'AuthenticationForm' has no attribute 'CharField'
Also in the login-page.html I have used the input tag whose type by default is set to text is there a way to change it to password ? As I have looped on fields in the form.
Kindly let me know where I am going wrong.
Thanks and Regards, Chinmay Swami