2

我一直在研究 Django-Mongodb 应用程序。我试图在我的项目中使用 django-registration 模块,但从未让它工作。

https://github.com/lig/django-registration-me

有人在他们的 django-nonrel 中使用过 django-registration 吗?如果你这样做,你能给我一些指示吗?既然用户模型在 django-nonrel 中,它应该是什么样子?

提前致谢,

4

1 回答 1

3

Since nobody really answered it, and I figured it out. I will just answer my own question as the reference for others who might be having the same problem.

I found it easier to use Mongoengine Authentication backend on top of Django authentication. Use the following in settings.py.

AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
)

SESSION_ENGINE = 'mongoengine.django.sessions'

https://mongoengine-odm.readthedocs.org/en/latest/django.html

Apart from that you use pretty much the same code as in regular django, and a bit different at accessing the user from request. Just need to:

from mongoengine.django.auth import User

And if you use form in django, you probably end up using form for mongodb instead. https://github.com/jschrewe/django-mongodbforms

于 2013-07-11T00:28:04.340 回答