Django contrib.auth.models.User与Django MongoDB引擎

Pur*_*ell 2 django django-models mongodb django-mongodb-engine

你可以使用contrib.auth.models.User或任何contrib.auth和Django MongoDB引擎吗?

我按照指示配置了MongoDB引擎,并且适用于自定义模型,但是:

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'
Run Code Online (Sandbox Code Playgroud)

有没有办法使用普通的用户模型和auth系统,还是我现在必须实现自己的?

如果它目前不受支持或者是未知的领域,那么有没有办法将用户存储在mysql中,所有我的mongodb引擎模型都存储在MongoDB中?

Jon*_* H. 5

除了需要JOIN(组,权限)的任何内容之外,您可以使用所有auth系统.

看起来你正在导入错误版本的Django(不是Django-nonrel,而是Django"vanilla").请确保您正在使用的virtualenv中只安装了Django-nonrel,以便导入无法进入错误的目录.

如果这不能解决您的问题,那么完整的回溯将非常有用.