Django Get All Users

Solution 1:

from django.contrib.auth import get_user_model
User = get_user_model()
users = User.objects.all()

Solution 2:

Django get user it's also simple method to get all user ,create user ,change password ,etc

from django.contrib.auth import get_user_model
user = get_user_model()
user.objects.all()

Solution 3:

from django.contrib.auth.models import User
userList =User.objects.values()

will return values of all user in list format from Django User table. User.objects.all() will returns object.

Solution 4:

Try this:

from django.contrib.auth.models import User
all_users = User.objects.values()
print(all_users)
print(all_users[0]['username'])

all_users will contain all the attributes of the user. Based upon your requirement you can filter out the records.