Simple JWT Usage

Question:

I have my Django backend authentication working (tested using curl and postman), but something eludes me. When sending test requests, the docs show username and password data being sent:

curl 
  -X POST 
  -H "Content-Type: application/JSON" 
  -d '{"username": "davidattenborough", "password": "boatymcboatface"}' 
  http://localhost:8000/api/token/

But, if I try to send an email and password instead, the response says that the username is a required field. Where and how can I change that behavior?

Thanks!

customUser model:

class CustomUser(AbstractUser):
    pass
Asked By: Selloum

||

Answers:

I think you define the two fields when you create your custom user model by inheriting from the AbstractUser model.

class CustomUser(AbstractUser):
    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['email']
Answered By: Metalgear