[Solved]-Django admin – You don't have permission to edit anything

13👍

Answering my question here. So the problem was, PermissionsMixin. What I thought was that PermissionsMixin will handle all the permssion related things. But even though I added the PermissionsMixin to the new user Model, I had to explicitly make the tell django that the superuser is indeed superuser by adding is_superuser or by has_perm.

So I changed my function inside the User manager to

def create_superuser(self, email, first_name, last_name, username, date_of_birth, password, **kwargs):
        user = self.create_user(
            email,
            first_name=first_name,
            last_name=last_name,
            username=username,
            date_of_birth=date_of_birth,
            password=password,
            is_superuser=True,
            **kwargs
        )

Hope this will help someone like me!

3👍

in 2020, you need to define two methods

def has_module_perms(self, app_label):
       return self.is_superuser
def has_perm(self, perm, obj=None):
       return self.is_superuser

also the model field is_superuser…you can rename the is_superuser field to is_admin or anything… for that case u will also need to change is_superuser to is_admin in your functions

0👍

In my case problem was in venv. Try to recreate it

👤some

Leave a comment