On Sat, Nov 3, 2012 at 11:15 PM, Michael Muster <
michael.mus...@googlemail.com> wrote:

> Hi again,
>
> I have a subclass from AbstractUser
>
> 1 from django.contrib.auth.models import AbstractUser
> 2 from django.conf import settings
> 3
> 4 class cpUser(AbstractUser):
> 5     twitter = models.CharField(max_length=100)
> 6     def __unicode__(self):
> 7         return self.username
>
> and
> AUTH_USER_MODEL = 'account.cpUser'
> in my settings.py set.
>
> How do i get a password field to set and reset
> a password in my admin app?
> Adding the password field to admin.py does obviously not
> work as it enters plain text and not the hashed password.
>
> 1 from django.contrib import admin
> 2 class cpUserAdmin(admin.ModelAdmin):
> 3    fields = ['twitter','username', 'first_name', 'last_name',
> 'password',]
> 4                                                                ~~~~~~~~
> 5 admin.site.register(cpUser, cpUserAdmin)
>
>
> Do i have to set a passwort field to the models.py or
> can i geht that from the models which i "abstracted" from
> (as done with username, first_name, last_name...)
>
> You need to follow the instructions that are in the documentation.

https://docs.djangoproject.com/en/dev/topics/auth/#custom-users-and-django-contrib-admin

The key is that you can't just subclass admin.ModelAdmin -- you need to
subclass the existing Django admin class for Users
(django.contrib.auth.admin.UserAdmin) - that base class is what provides
all the special password handling etc for User models.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to