Opened 17 years ago
Closed 16 years ago
#9656 closed (duplicate)
Inherit user's password change link doesn't work
| Reported by: | Maxim Syabro | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.0 |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I've created user:
class WTUser(User): authtype = models.IntegerField('Authtype', blank=True, null=True, choices = AUTH_TYPES) objects = UserManager()
In Admin site I've clicked on WTUser->create new. Instead of enetering login, password and password confirm I've got a big form with all fields.
Next when I click an link "change password" in WTUser edit form, which links to /admin/westtravel/wtuser/password/ and got
Page not found (404)Request Method: GET Request URL: http://127.0.0.1:8000/admin/westtravel/wtuser/password/ wt user object with primary key u'password' does not exist.
Change History (9)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
| Description: | modified (diff) |
|---|
Fixed description. If only there was some kind of preview button people could use to check before submitting. Oh, wait ... there is.
comment:4 by , 17 years ago
| milestone: | → 1.1 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:5 by , 17 years ago
This occurs because you didn't inherit the user's ModelAdmin where that view is defined, this should be documented at a minimum.
comment:6 by , 17 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
You probably want to subclass django.contrib.auth.admin.UserAdmin.
comment:7 by , 16 years ago
| Resolution: | wontfix |
|---|---|
| Status: | closed → reopened |
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.
comment:9 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | reopened → closed |
The larger issue here is that people want to use different User models, both in admin and in their own code. We need a way to make this easier. I'm going to close this as a dupe of #3011, since that is the ticket for tracking custom User models.
Please replace an '[' and ']' with '
' and ''