django-rest-framework-mongoengine-example icon indicating copy to clipboard operation
django-rest-framework-mongoengine-example copied to clipboard

How to create new user and login?

Open miamor opened this issue 6 years ago • 1 comments

Hello, I have managed to install and run your example, however I cannot createsuperuser to login to admin as well as I don't know how to create new user, how to login to get token. Could you help me on how to create new user, how to login, and can I use django admin panel for this? Also, after installing and migrating I don't see any new database created in mongo, is it okay or did I miss on something?

miamor avatar Sep 09 '19 04:09 miamor

I believe, this example should be using version of Mongoengine like 0.8.

In order to run management commands such as createsuperuser or createuser, it should rely upon mongoengine.django.auth module, which contains some implementations of those commands: https://github.com/MongoEngine/mongoengine/blob/0.8/mongoengine/django/auth.py#L140.

As for the authentication code with TokenAuthentication, it should reside in https://github.com/BurkovBA/django-rest-framework-mongoengine-example/blob/master/project/users/authentication.py. You just use the TokenAuthentication class in authentication_classes of your views: https://www.django-rest-framework.org/api-guide/authentication/.

If you need to implement login page, see: https://github.com/BurkovBA/django-rest-framework-mongoengine-example/blob/master/project/users/views.py

BurkovBA avatar Oct 10 '19 10:10 BurkovBA