Django Get All Users

前端 未结 4 666
执念已碎
执念已碎 2020-12-24 01:08

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 =         


        
4条回答
  •  礼貌的吻别
    2020-12-24 01:34

    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.

提交回复
热议问题