Custom pipeline or extend user model
Hi,
I am implementing social-app-django with django 1.11 (not using Mongo). My application will need to store and manipulate a lot of data on users other than that which is fetched from their social media accounts at login. I don't need to fetch or collect any extra data when the user authenticates, but various actions they perform on my site will need to be saved to their user. I am wondering which of the following approaches is preferred (I've searched extensively online, but can't find a specific explanation of the differences):
-
Create my own user model in my app's models.py (call it
MyUser) that doesn't extend anything special, and then add a function in the authentication pipeline that associates the social-app-django user with a corresponding instance ofMyUser. or... -
Create my own user model in my app's models.py, and in the project's settings.py set
AUTH_USER_MODELandSOCIAL_AUTH_USER_MODELto point toMyUser. In this case, I was wondering whether someone could clarify what MyUser and its manager should extend, and what I need to import in modules.py (I am confused because a lot of stack overflow posts are referring to deprecated versions of this module and I keep getting errors). Also, in this case should I be setting bothAUTH_USER_MODELandSOCIAL_AUTH_USER_MODEL, or just one of them?
Do these two methods essentially achieve the same thing? Is one more reliable/preferred for some reason? Or, should I be doing both? Thanks very much for any assistance.
Oh, and one more thing--I would like to be able to access the User database not only from the app I am currently building, but also from other apps (within the same Django project) that I will build in the future. Does this affect anything?
I agree there really needs to be some clarification about the use of the SOCIAL_AUTH_USER_MODEL setting. I'm confused as to where and how the value of SOCIAL_AUTH_USER_MODEL is even used in the library and also how it differs from Django's own AUTH_USER_MODEL setting. There's little said in the documentation about how to actually use SOCIAL_AUTH_USER_MODEL with a custom model besides saying that it requires the username and email model fields to be present. I made a custom Django Social Auth user model and set SOCIAL_AUTH_USER_MODEL to it but whenever I'm logged into Django admin I get a conflict:
ValueError: Cannot query "<staff superuser name>": Must be "<SOCIAL_AUTH_USER_MODEL model class>" instance.
Perhaps the python-social-auth/social-examples repository can add a full example in which SOCIAL_AUTH_USER_MODEL is used to point to a separate model than AUTH_USER_MODEL.
If it's possible I'd ideally like keep complete separation between Django staff/Django Users and Django Social Auth users that I integrate into my custom model, but allow simultaneous login to Django Admin and Django Social Auth. So basically 2 entirely separate authentication systems.
Hello, any updates on this?