Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

token_obtain_pair check email

#by default, TokenObtainPairView takes 'username' and 'password' as user
#credentials. This snippet makes them 'email' and 'password'
#https://stackoverflow.com/questions/54157056/how-can-i-use-email-in-django-rest-framework-simplejwt-instead-of-username
from rest_framework_simplejwt.views import TokenObtainPairView
from rest_framework_simplejwt.serializers import (
    TokenObtainPairSerializer, User
)

class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
    username_field = User.EMAIL_FIELD


class EmailTokenObtainPairView(TokenObtainPairView):
    serializer_class = CustomTokenObtainPairSerializer

Comment

PREVIOUS NEXT
Code Example
Python :: pandas show all dataframe 
Python :: Solving environment: failed with initial frozen solve. retrying with flexible solve 
Python :: python series sort 
Python :: how to cnovert a decimal to fraction python 
Python :: pandas not is in 
Python :: python dict to url params 
Python :: seaborn plot dpi 
Python :: skip header in csv python 
Python :: create empty csv file in python 
Python :: numpy random int 
Python :: python detect keypress 
Python :: django import settings 
Python :: run code with different verions of python 
Python :: pandas resample backfill 
Python :: talos get best model 
Python :: pickle save 
Python :: python join list with comma 
Python :: Embed picture in email using smtplib 
Python :: python selenium itemprop 
Python :: graphics in python in repl 
Python :: how to recurse a function 
Python :: python index where true 
Python :: colorama 
Python :: python dynamic loop 
Python :: print the heat map python 
Python :: python multiply matrices 
Python :: DataFrame.plot.line() method: | dataframe line plot 
Python :: streamlit st.file_uploader 
Python :: convert categorical variable to numeric python 
Python :: rename coordinate netcdf python xarray 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =