Coder Social home page Coder Social logo

Comments (6)

whatcould avatar whatcould commented on August 22, 2024 3

For others with this issue: In an existing app with multiple authentication backends (including login by email), I was confused when I passed "email" and "password" fields and DRF-simplejwt returned {"username":["This field is required."]}.

All I had to do was pass the email as the username — don't change the field name to 'email'.

from djangorestframework-simplejwt.

davesque avatar davesque commented on August 22, 2024 3

@whatcould Right. The login serializer just uses the username field defined on the user model. I don't think there's any way it could properly account for the behavior of non-standard authentication backends.

from djangorestframework-simplejwt.

nourani avatar nourani commented on August 22, 2024

+1 from me. However, I don't think this is an issue but rather a feature?

from djangorestframework-simplejwt.

gabn88 avatar gabn88 commented on August 22, 2024

Authentication is done using the authenticate method of django.contrib.auth. Therefore you can modify its behaviour by modifying the AUTHENTICATION_BACKENDS setting in settings.py.

Your question has nothing to do with this package, please close.

from djangorestframework-simplejwt.

davesque avatar davesque commented on August 22, 2024

What @gabn88 says is correct, actually. Take a look here. Will close this since it seems out of scope for simple jwt.

from djangorestframework-simplejwt.

Lepiloff avatar Lepiloff commented on August 22, 2024

Based on stackowerflow answer https://stackoverflow.com/questions/37332190/django-login-with-email

use this link for update default User model and change username field to email
https://stackoverflow.com/questions/37332190/django-login-with-email

from djangorestframework-simplejwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.