Reputation: 7515
I am trying to create my own authentication system by making use of Django Auth module. The problem is when I print my form in the template, Username and text field is displaying fine but the password field its displaying object something like this <django.forms.widgets.PasswordInput object at 0x00000000039E1710>
Here is my form
class UserLoginForm(forms.Form):
username = forms.CharField(required = True)
password = forms.PasswordInput(render_value = True)
And the template goes here.
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
<form method="post" action="/portal/login">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
Some one help me on this
-Vikram
Upvotes: 0
Views: 1605
Reputation: 7515
OK, I got the answer: After correcting the form like this its displaying fine
class UserLoginForm(forms.Form):
username = forms.CharField(required = True)
password = forms.CharField(widget=forms.PasswordInput())
Sorry for the spam
-Vikram
Upvotes: 0
Reputation: 4267
change
password = forms.PasswordInput(render_value = True)
to
password = forms.CharField(widget=forms.PasswordInput(render_value = True))
Upvotes: 4