Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From the django shell how do you list staff users

I am trying to add a field to the user profile and need to confirm that the user is staff and active but i cannot figure out a command that will display this.

thanks

like image 702
JHub42 Avatar asked Sep 17 '25 22:09

JHub42


1 Answers

You can adapt:

from django.contrib.auth.models import User
active_staff = User.objects.filter(is_active=True, is_staff=True)

You could add in a username= or similar and if you get an empty result, then you know they don't match the criteria. For info on what's in the default model, see django.contrib.auth.

like image 87
Jon Clements Avatar answered Sep 19 '25 11:09

Jon Clements