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.

Change History (1)

comment:1 by Russell Keith-Magee, 10 years ago

Resolution: invalid
Status: newclosed

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 for MyUser, so we're not looking to exploit flexible model definitions; if you're not using MyUser, 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 the UserChangeForm and UserCreationForm.

Note: See TracTickets for help on using tickets.
Back to Top