Opened 10 years ago
Closed 10 years ago
#22723 closed Cleanup/optimization (invalid)
Substituting a custom User model doesn't use get_user_model() properly
Reported by: | hgezim | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | custom user model |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In the Substituting a custom User model section of the documentation, A full example subsection imports the custom user model as such:
from customauth.models import MyUser
instead stead of using get_user_model()
from django.contrib.auth
.
Note:
See TracTickets
for help on using tickets.
In this case, importing the actual model is correct. The import is occurring in the admin definition file, which is setting up the admin for
MyUser
. This admin definition will *only* work forMyUser
, so we're not looking to exploit flexible model definitions; if you're not usingMyUser
, you won't be using this admin definition.Additional proof of this --
get_user_model()
calls shouldn't be made at the module level, which would be required in order to set up theUserChangeForm
andUserCreationForm
.