Search code examples
djangomongodbdjango-modelsdjango-mongodb-engine

Django contrib.auth.models.User with Django MongoDB Engine


Can you use contrib.auth.models.User or any of contrib.auth along with Django MongoDB Engine?

I have MongoDB Engine configured as directed and working fine for custom models but:

from django.contrib.auth.models import User
a = User.objects.create_user(username='foo', email='[email protected]',
                             password='foo123bar')
a.save()
    ...
    ERROR: An unexpected error occurred while tokenizing input
    The following traceback may be corrupted or invalid
    The error message is: ('EOF in multi-line statement', (5, 0))
    ...

    ValueError: invalid literal for int() with base 10: '4f3757d4eb60261dae000001'

Is there a way to use the normal User models and auth system or do I now have to implement my own?

If it is not currently supported or is uncharted territory, could there be a way that Users are stored in mysql and all my mongodb engine models are stored in MongoDB?


Solution

  • You can use all of the auth system except for anything that needs JOINs (groups, permissions).

    It looks like you're importing the wrong version of Django (not Django-nonrel, but Django "vanilla"). Please make sure that only Django-nonrel is installed in the virtualenv you're working in so that imports can not go to the wrong directory.

    If this doesn't fix your issues, a complete traceback would be really helpful.