Vikram Vikram - 1 year ago 90
Python Question

Django PasswordInput is printing object instead of form field

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 %}
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>

<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />

Some one help me on this


Answer Source


password = forms.PasswordInput(render_value = True)


password = forms.CharField(widget=forms.PasswordInput(render_value = True))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download