Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django authenticate with email

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 :: convert number to char python 
Python :: python argparser flags 
Python :: python os get dir path 
Python :: loads function in json python 
Python :: python spawn process 
Python :: keras conv2d 
Python :: python run bat in new cmd window 
Python :: .items() python 
Python :: obtain items in directory and subdirectories 
Python :: write string python 
Python :: poerty python macos 
Python :: continue and break in python 
Python :: numpy evenly spaced numbers 
Python :: dataframe multiindex 
Python :: tkinter mainloop 
Python :: remove french stopwords with spacy 
Python :: draw picture in python libraries 
Python :: pandas split column into multiple columns 
Python :: smtp django 
Python :: inconsistent use of tabs and spaces in indentation 
Python :: phyton 2.7 convert timedelta to string 
Python :: array creation in numpy 
Python :: array with zeros python 
Python :: convert int to string python 
Python :: add a column with initial value to an existing dataframe 
Python :: how to get only one column from dataset in python 
Python :: k fold cross validation from scratch python 
Python :: pandas split list in column to rows 
Python :: how to check if a list is empty 
Python :: python use variable inside pandas query 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =