Skip to content

Instantly share code, notes, and snippets.

@gen1us2k
Created December 4, 2019 08:16
from django.http import JsonResponse
from django.contrib.auth.models import User
def fetch_users(request):
return JsonResponse({"users": [{
"username": u.username, "first_name": u.first_name,
"last_name": u.last_name, "id": u.pk} for u in User.objects.all()]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment