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

Extending mongoengine User model for SOCIAL_AUTH_USER_MODEL #70

Closed
Diolor opened this issue Nov 5, 2013 · 4 comments
Closed

Extending mongoengine User model for SOCIAL_AUTH_USER_MODEL #70

Diolor opened this issue Nov 5, 2013 · 4 comments

Comments

@Diolor
Copy link

Diolor commented Nov 5, 2013

I need some help creating a custom User model, in order to extend it.

My models.py is :

from mongoengine.django.auth import User 

class User(User):
    """Extend Mongo Engine User model"""
    foo = ListField(default=[])

So I have updated the settings.py with:

MONGOENGINE_USER_DOCUMENT = 'apps.models.User'
AUTH_USER_MODEL =  'mongo_auth.MongoUser'
SOCIAL_AUTH_USER_MODEL =  'apps.models.User'

However on login I get:

ValidationError: ValidationError (UserSocialAuth:526fab8ac36b440b4a8f080b) (A ReferenceField only accepts DBRef or documents: ['user'])

I checked I saw that the 526fab8ac36b440b4a8f080b id is the user id in user_social_auth collection.

@omab
Copy link
Owner

omab commented Nov 5, 2013

I wasn't able to reproduce your error so far. Why are you defining AUTH_USER_MODEL to be different than the others?

@Diolor
Copy link
Author

Diolor commented Nov 5, 2013

It looked it was a migration problem. The database was complaining to the new structure of the user and user_social_auth. The only clue is possibly because the foo =[] was not there. I deleted these two user collections (it is luckily in dev) and then run smoothly. No clue how to fix this if you do not want to delete the user collections.

I commented out the AUTH_USER_MODEL which was not necessary; if that had to do something.

branden pushed a commit to branden/python-social-auth that referenced this issue Nov 5, 2013
@omab
Copy link
Owner

omab commented Nov 9, 2013

Looks like a mongoengine issue to me than PSA. Reopen if needed.

@omab omab closed this as completed Nov 9, 2013
@Diolor
Copy link
Author

Diolor commented Nov 11, 2013

Ok I found the problem. Just for the records, it was a MongoDB user authentication/privileges level.

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

2 participants