2

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?

1
  • 1
    @Purell Jonas is author of django-mongodb, so follow his instruction :) The reason for this error is Django(vanilla) has primary key as int, which got fixed in django nonrel patch and converted to string. In your case, Django trying to convert mongodb object id '4f3757d4eb60261dae000001' to int, which is causing problem. Commented Feb 12, 2012 at 13:20

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.