Django: PasswordInput is empty

Viewed 772

I have a simple Django model:

class Remote(models.Model):
    password = models.CharField(max_length=256, blank=True)

and admin.py:

class RemoteForm(forms.ModelForm):
    class Meta:
        widgets = {
            'password': forms.PasswordInput(),
        }

class RemoteAdmin(ForStaffModelAdmin):
    form = RemoteForm

admin.site.register(Remote, RemoteAdmin)

If I open the change_view for an instance in the django admin, then the password field is empty. I checked the db: the instance has a password.

Why is PasswordInput empty?

I would like to see "********"

1 Answers

Don't ask me why, but this works. I added render_value=True.

class RemoteForm(forms.ModelForm):
    class Meta:
        widgets = {
            'password': forms.PasswordInput(render_value=True),
        }

Docs of PasswordInput

Related