Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to login using email in django

from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend

class EmailBackend(ModelBackend):
    def authenticate(self, request, username=None, password=None, **kwargs):
        UserModel = get_user_model()
        try:
            user = UserModel.objects.get(email=username)
        except UserModel.DoesNotExist:
            return None
        else:
            if user.check_password(password):
                return user
        return None
Comment

PREVIOUS NEXT
Code Example
Python :: send api request python 
Python :: Change Python interpreter in pycharm 
Python :: permutation python 
Python :: django sign up 
Python :: arrayfield in django 
Python :: max deviation in pandas 
Python :: modern tkinter 
Python :: time.sleep() python 
Python :: matplotlib plot in second axis 
Python :: IQR to remove outlier 
Python :: spark.read.load 
Python :: python expand nested list 
Python :: how to create pyw file 
Python :: numpy indexing arrays 
Python :: pygame check collision 
Python :: python dataframe save 
Python :: Python Tkinter PanedWindow Widget 
Python :: join lists python 
Python :: import login required 
Python :: streamlit sidebar width 
Python :: get column index pandas 
Python :: pandas como quitar comillas simples de una columna 
Python :: download unsplash images python no api 
Python :: how to decrease size of graph in plt.scatter 
Python :: how to get the most common number in python 
Python :: print without newline 
Python :: pandas access multiindex column 
Python :: pil format multiline text 
Python :: matplotlib 
Python :: matrix diagonal sum leetcode 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =