Adam Adam - 1 year ago 224
Python Question

Django Get All Users

I am just starting out with Django and I am messing around just trying to pull a full list of users from postgres.

I used the following code:

group = Group.objects.get(name="Admins")
usersList = group.user_set.all()

How could you pull all users? I don't want to have to pick or assign a group.

group = Group.objects.get() #Doesn't Work.
usersList = group.user_set.all()

Answer Source
from django.contrib.auth.models import User

users = User.objects.all()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download