0

How can we login with username or password in Django site and Django Admin pages?

I tried by creating custom user model and making email field as username field but I can don't want to login with either username or email.

I want to use any of both any time to login.

2

1 Answer 1

0

You can use { from django.db.models import Q

Example:

from django.db.models import Q user = "username/eamil" password= "your password" user_check = models.YourModelName.objects.filter((Q(email = user)|Q(username = user)), password = password) 

}

Sign up to request clarification or add additional context in comments.

1 Comment

Welcome to StackOverflow. When posting code, paste it, select it, and then click the {} widget to render it as text.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.