Search code examples
djangomongodbdjango-registrationdjango-nonrel

Django-registration with mongoengine and Django?


I've been working on a Django-Mongodb application. I was trying to use django-registration module in my project, but never got it to work.

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

Have anyone used django-registration in their django-nonrel? If you do, can you point me some instructions? What should User model look like since it is in django-nonrel?

Thanks in advance,


Solution

  • 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