DEV Community

Discussion on: User registration and authorization on a django API with djoser and JSON web tokens.

Collapse
 
lgalant profile image
Leandro Galanterni

Hey great posting, I'm trying to achieve the exact same thing you are doing but I'm not sure how to create a new profile. What I want to do is call the POST /auth/users method with additional fields so that it creates the profile and the user at the same time. Is this realistic? Or I need to perform 2 steps (i.e. one call to create the user and a second call to create the profile)
Thanks in advance!

Collapse
 
lewiskori profile image
Lewis kori

Hey. Yes it would.

The best way to add extra fields is to extend django user model with AbstractUser, then place those extra fields in the REQUIRED_FIELDS array.
That way the djoser /auth/users/ endpoints can recognize the additional fields on the CustomUser model.

I had initially made the user profile to demonstrate signals to the readers :)

You can use django's AbstractUser Class to extend the user model. Here's the documentation