On Thu, May 12, 2011 at 09:51:24AM -0700, Gabe wrote: > First of all thx for all replies. > > For now I don`t use auth.User model I would like to create my own. So > I have written model class Users: > > [...] > > Then I have registered it in admin panel by editing admin.py among > with another models: > > from django.contrib import admin > from dgcmsUser.models import Users > from dgcmsUser.models import Priviledges > from dgcmsUser.models import UsersProfiles > > admin.site.register(Users) > admin.site.register(UsersProfiles) > admin.site.register(Priviledges) > > > Then when I add user using autogenerated admin panel the password > field is <input type="text" /> not <input type="password" /> which I > would like it to be.
You have to create a custom ModelForm for your Users model. This form will only have to override the widget of the password field. Then you'll have to create a custom ModelAdmin specifying your ModelForm instead of the default one. It may look something like this (note that I'm typing off the top of my head): class UserForm(forms.ModelForm): class Meta: widgets = { 'password': PasswordInput, } class UserAdmin(admin.ModelAdmin): form = UserForm admin.site.register(User, UserAdmin) OT: Note that each time someone saves a plaintext password in a database, a kitten dies. Please, think of the kittens. (-; (Also applies to base64-encoded passwords and such. Yeah, you wouldn't believe it but the academic information system our university forces us to use does exactly that. Probably because of unicode encoding issues.) Michal
signature.asc
Description: Digital signature