开发者

modify admin auth backend

开发者 https://www.devze.com 2023-01-05 18:06 出处:网络
By default, after authentication on /admin, function authenticate() returns User object, what if i want to get proxy model for the User (i.g. called HandyUser) in return ? In my pr开发者_C百科oject, i

By default, after authentication on /admin, function authenticate() returns User object,

what if i want to get proxy model for the User (i.g. called HandyUser) in return ? In my pr开发者_C百科oject, in all custom auth backends, i'm using HandyUser instead of User.

thanks


According to the django docs http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-user, you need to add to your settings file:

AUTH_PROFILE_MODULE = 'app.HandyUser'

And then when you reference your User class, call the user.get_profile method which will return the instance of HandyUser.

0

精彩评论

暂无评论...
验证码 换一张
取 消