#9656: Inherit user's password change link doesn't work
-------------------------------------------+--------------------------------
          Reporter:  syabro                |         Owner:  nobody
            Status:  reopened              |     Milestone:  1.1   
         Component:  django.contrib.admin  |       Version:  1.0   
        Resolution:                        |      Keywords:        
             Stage:  Accepted              |     Has_patch:  0     
        Needs_docs:  0                     |   Needs_tests:  0     
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by AdamTwiss):

  * status:  closed => reopened
  * resolution:  wontfix =>

Comment:

 I keep encountering the same problem as per this original ticket.
 Subclassing from UserAdmin doesn't itself fix it.

 My code is:
 models.py:
 {{{
 class Player( User ):
         # Other stuff snipped
         objects = UserManager()
 }}}

 Using Django 1.1 (or 1.02)

 If I just do this, then the change_password link is broken as described.
 If I then set the admin

 admin.py:
 {{{
 class PlayerAdmin( UserAdmin ):
         pass
 admin.site.register(Player, PlayerAdmin )
 }}}

 Then at this point adding a Player in the admin interface just creates a
 User when added, and shows an error of:
 http://localhost:8000/admin/website/player/4/

 To get it to work I need to extend admin.py to do a minimum of:

 {{{
 from django.contrib.auth.admin import UserAdmin
 from django.contrib.auth.forms import UserCreationForm
 from django.utils.translation import ugettext, ugettext_lazy as _

 class PlayerAddForm( UserCreationForm ):
         class Meta:
                 model = Player
                 fields = ("username","first_name", "last_name" )
         def __init__(self, *args, **kwargs):
                 return super(PlayerAddForm,self).__init__( *args,
 **kwargs)


 class PlayerAdminForm(forms.ModelForm):
         class Meta:
                 model = Player
         password = forms.CharField( help_text=_("Use
 '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change
 password form</a>."))


 class PlayerAdmin( UserAdmin ):
         form = PlayerAdminForm
         add_form = PlayerAddForm

 admin.site.register(Player, PlayerAdmin )
 }}}

 The fact that this is undocumented and it's taken me a while to figure it
 out is to me a bug in itself.

 If the 'correct' thing to do now is to extend the Auth.User class (rather
 than user user_profile), then I also think this should be made easier in
 some way as it's less than obvious and lacks the djangoesque simplicity.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9656#comment:7>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to