User form has fields with unwanted initial value, Django
<p>I'm trying to create a view to allow a User to create another User. The problem is that the generated form has initial values for the 'password' and 'last_name' fields, and I don't know why. I need to remove those initial values.</p>

<p>I have created a UserForm with ModelForm.</p>

<pre><code>class UserForm(forms.ModelForm):
    # I've tried this, but it doesn't change anything
    #def __init__(self, *args, **kwargs):
        #super(UserForm, self).__init__(*args, **kwargs)
        #self.fields['password'].value = ''
        #self.fields['last_name'].value = ''

    password = forms.CharField(widget=forms.PasswordInput(render_value=True))

    class Meta:
        model = User
        fields = [
            'username', 'email', 'first_name', 'last_name'
        ]
</code></pre>

<p>Then I have the view. I have coded the view following the same pattern for creating views for other objects. After having this problem, I wrote the view down to this:</p>

<pre><code>def create_user(request):
    user_form = UserForm()

    context = {
        "user_form": user_form,
    }
    return render(request, "remote/user/user_create_form.html", context)
</code></pre>

<p>I was hoping that if I only tried to display the form, and not treat the form data, this problem would not appear, but it does.</p>

<p>My template has this (I'm using crispy forms): </p>

<pre><code>&lt;form action="" method="POST"&gt;{% csrf_token %}
    {{ user_form|crispy }}
    &lt;input type="submit" class="btn btn-primary" value="Registar" /&gt;
&lt;/form&gt;
</code></pre>

<p>Here is what the form looks like initially:
<a href="http://i.stack.imgur.com/wTt4d.png" rel="nofollow">password and last_name fields have initial values</a></p>

<p>It's because while testing,You might have used browser feature of saving the field and form data i.e. autosave the password.It generally saves the password and just previous field of the form.Please clear your cache and form autofill data from browser settings. Let us know if the error still exists.
Thanks</p>

python django django-forms user