BurkovBA / django-rest-framework-mongoengine-example

django-rest-framework-mongoengine-example
83 stars 45 forks source link

Creating new user #7

Closed edwinharly closed 6 years ago

edwinharly commented 6 years ago

Hi there, if I want to create a new user through POST request on users endpoint, do I need to define a post function on UserViewSet class ? Or maybe there's already an existing way to create user through some endpoint ? Thanks.

franciscbalint commented 6 years ago

You need to overwrite the default user class (not recommended) https://stackoverflow.com/questions/21072595/mongoengine-how-to-custom-user-model-custom-backend-for-authenticate

edwinharly commented 6 years ago

So, what is the recommended way to handle user registration ?

franciscbalint commented 6 years ago

"In retrospect, I guess the moral is: never use Mongo just because it's cool. Mongo is still a second-class citizen in the Django world."

I used MongoDB for custom models and let default models on postgres.

BurkovBA commented 6 years ago

@edwinharly Yes, I think, you need to add a custom create() method for UserViewSet.

As for how users system works in Django with Mongoengine: Mongoengine 0.9- contains a django submodule, which implements a dummy Django model that proxies all the meaningful action to a Mongoengine user document.