1👍
✅
Here is an example of solving this issue based on yassam’s answer above. The code I had that was causing the problem:
class MyCustomModelBackend(object):
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username__iexact=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
To solve this issue, update it to to derive from django.contrib.auth.backends.ModelBackend
:
from django.contrib.auth.backends import ModelBackend
class MyCustomModelBackend(ModelBackend):
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username__iexact=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
1👍
Are you using your own authentication backend? If so, does your backend class derive from django.contrib.auth.backends.ModelBackend?
I discovered the same problem in my code today, and the problem turned out to be that my backend was derived from object. In particular, my backend didn’t implement some of the functions used by the admin code (such as has_module_perms).
Either derive your backend from django.contrib.auth.backends.ModelBackend, or make sure that all the functions needed by the admin code are defined in your backend.
- [Answered ]-Django URL explanation
- [Answered ]-Set text in bold and vertical space with Django EmailMessage
Source:stackexchange.com