Amol_G
Amol_G

Reputation: 367

In django admin panel permissions given to the users by group not working

In Django admin panel I create groups and give permission to them.

eg: Create a Student Group and give it permission to view the student model. Create a Teacher Group and give it permission to view the student model and add the student model.

create user using API and added to those groups, and also staff status checked for each user.

When users log in on the admin panel that shows Site administration You don’t have permission to view or edit anything.

How to solve it.

Upvotes: 1

Views: 1120

Answers (2)

Uzair Ullah
Uzair Ullah

Reputation: 1

Add this line to the AUTHENTICATION_BACKENDS

'django.contrib.auth.backends.ModelBackend',

in my case I updated the

AUTHENTICATION_BACKENDS

AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'core.backends.EmailBackend',
]

and this worked,

Upvotes: 0

Abdullah
Abdullah

Reputation: 11

I've got the same issue, tried every solution out there but they're all either outdated or not useful to my case. First let me ask you some questions.

1- What version of django are you using?

2- Do you have ModelBackend set in your AUTHENTICATION_BACKENDS like that?

AUTHENTICATION_BACKENDS = [
    ...
    "django.contrib.auth.backends.ModelBackend",
    ...
]

3- If you're using a custom user model, have you extended PermissionsMixin in your class like that?

class CustomUser(AbstractBaseUser, PermissionsMixin):
    # Fields

If you've done all of that and still stuck at it, like myself, then i'm not really sure what could help us. Anyway, i'll keep you posted if i get to know anything else.

Upvotes: 0

Related Questions