Answer the question
In order to leave comments, you need to log in
How to override has_perm method in Django?
Hello! Please help me figure it out.
I ran into the following problem. There is a superuser who lacks one right (for example, use_tool rights). When checking the use_tool permission for this user, I expected that it would return False, since this user does not have this right, although he is a superuser. It always returns True.
views.py:
if user.has_perm("use_tool"):
print "True"
else:
print "False"
User -> AbstractUser -> AbstractBaseUser, PermissionMixin
def has_perm(self, perm, obj=None):
if self.is_active and self.is_superuser: <-- Проблема вызывается из-за данной строки
return True
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question