Reputation: 772
How would I automatically set is_staff to True when creating a new user in the Django admin when they have a specific group selected?
Upvotes: 0
Views: 929
Reputation:
The best way to achieve it using the django signal.
Just listen when a user created or updated its group. when it is created or updated with the specific group selected, You just set is_staff=True and save it.
To learn more about Django signal: https://docs.djangoproject.com/en/3.2/topics/signals/
Learn more about Django group and permission https://docs.djangoproject.com/en/3.2/ref/contrib/auth/#django.contrib.auth.models.User.groups
Upvotes: 1