[Django]-How can we get all usernames list only not user objects with django ORM

2👍

receivers=User.objects.values_list('username', flat=True)

Try this code, you can read more about this in django offical documents

1👍

receivers = User.objects.all().values_list('username')

It will return list of all usernames.

Leave a comment