Opened 9 years ago

Closed 9 years ago

#16379 closed Bug (invalid)

Override UserManager

Reported by: thibaultj Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Normal Keywords: auth, user, manager, usermanager
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In contrib.auth, the User class is affected a custom UserManager manager. I cannot find any clean way to override this manager, or to define a new one.

This is a problem in the following case: I created a middleware to manage acl. So in every request, I need to access request.user.profile.something. I'd like to override the get_query_set() method of the UserManager, to use select_related().

The only possible solution seems to monkey patch user class in a middleware, as suggested here :

Change History (2)

comment:1 Changed 9 years ago by Florian Apolloner

Use to attach to the User class registration and then use manager.contribute_to_class to attach your manager. Even if it doesn't work, I don't think anything should be changed now since app-refactor will provide that afaik.

comment:2 Changed 9 years ago by Aymeric Augustin

Resolution: invalid
Status: newclosed

This is more a usage question than a bug in Django, and apollo13 provided a solution.

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