I have a Django site in which the site admin inputs their Twitter Username/Password in order to use the Twitter API. The Model is set up like this:
class TwitterUser(models.Model):
screen_name = models.CharField(max_length=100)
password = models.CharField(max_length=255)
def __unicode__(self):
return self.screen_name
I need the Admin site to display the password field as a password input, but can’t seem to figure out how to do it. I have tried using a ModelAdmin class, a ModelAdmin with a ModelForm, but can’t seem to figure out how to make django display that form as a password input…
From the docs, you can build your own form, something like this:
Or you can do it like this:
I’ve no idea which one is better – I slightly prefer the first one, since it means you’ll still get any
help_textandverbose_namefrom your model.Regardless of which of those two approaches you take, you can then make the admin use your form like this (in your app’s
admin.py):