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='foo@bar.com',
                             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?

Nicolas Cortot
  • 6,591
  • 34
  • 44
Purrell
  • 12,461
  • 16
  • 58
  • 70
  • 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. – Gagandeep Singh Feb 12 '12 at 13:20

1 Answers1

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.

Jonas H.
  • 2,331
  • 4
  • 17
  • 23