Ayush Sinha
Ayush Sinha

Reputation: 55

Django JWT Auth for custom model

I have a custom user model

class User(models.Model):
    fields...

It also has a email, password field among other detail fields. I want to use the simplejwt JWT authorization which takes email and password as input and generates JWT Tokens. Most tutorials include creating a superuser and passing username password of the superuser to get the token, But I want to do this for my custom user model.

Upvotes: 2

Views: 1813

Answers (1)

Araelath
Araelath

Reputation: 595

django-simple-jwt generates the access and refresh tokens through the obtainTokenPairView. This views calls the authenticate function from django. Therefore if you have set up a custom user model following django guidelines, to use the email in place of the username, django-simple-jwt should work out of the box

Otherwise, you still have the option to create your own view and Generate the tokens manually

Upvotes: 0

Related Questions