Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"UserSocialAuth.user" must be a "MyUser" instance #631

Closed
blackrosezy opened this issue May 26, 2015 · 1 comment
Closed

"UserSocialAuth.user" must be a "MyUser" instance #631

blackrosezy opened this issue May 26, 2015 · 1 comment

Comments

@blackrosezy
Copy link

Hi,

I am using custom user model and keep getting the following error:

Django Version: 1.8.2
Exception Type: ValueError
Exception Value:    
Cannot assign "'38ce3451a9d68210ad038b09fb29b0df7b58e46a'": "UserSocialAuth.user" must be a "MyUser" instance.
Exception Location: C:\Users\Ohm\Desktop\app_virt\lib\site-packages\django\db\models\fields\related.py in __set__, line 627
Python Executable:  C:\Users\Ohm\Desktop\app_virt\Scripts\python.exe
Python Version: 2.7.9

My setttings in settings.py are:

AUTH_USER_MODEL = 'authentication.MyUser'

SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL

Could somebody spot the issue? Thank you.

@blackrosezy
Copy link
Author

I have found the issue. My create_user function returns string instead of user object:

WRONG:
    def create_user(self, email=None, password=None):
        .......
        user.save()
        return user.new_email_key <---------------- (x)
CORRECT:
    def create_user(self, email=None, password=None):
        .......
        user.save()
        return user <---------------- (/)

I have also found that the SOCIAL_AUTH_USER_MODEL variable is not required when using custom user model in Django (the app automatic get the value from AUTH_USER_MODEL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant