Opened 16 years ago
Closed 16 years ago
#11406 closed (duplicate)
Admin broken for subclasses of User
| Reported by: | Jim Garrison | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.0 |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I have a model called Teacher, which inherits from django.contrib.auth.models.User.
Here's the story: the "Add Teacher" form in the admin uses the form typically used for editing a user, so you have to type in a fake password string for it to accept the new Teacher. Further, the link to the "change password form" is broken.
Nothing I have said so far is new, however, as this is the subject of ticket #9656. This ticket was closed, saying that the person ought to be subclassing from django.contrib.auth.admin.UserAdmin anyway.
I am filing this ticket because such subclassing from UserAdmin creates additional problems that are even worse than the above issues. In particular,
- If you submit the "Add Teacher" form, a
Useris created, but a correspondingTeacheris not. - After editing a
Teacher, it redirects to the edit page for "teacher/[id]/", except it uses the id from theUsertable, not theTeachertable. I have only been able to reproduce this using MySQL; sqlite does not give me this error.
In short, deriving from UserAdmin currently creates more problems than it solves.
I'm pretty sure the issues that you've raised can be overcome - it's just a matter of writing the right code for UserAdmin. #9656 contains a fully worked example of how to get this to work; consult django-users for more assistance.
However, there's a larger issue here: 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.