Skip to content

Instantly share code, notes, and snippets.

@TSKGunGun
Created October 28, 2021 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TSKGunGun/af83f9e23b71f468c8b2102a37b3ebc2 to your computer and use it in GitHub Desktop.
Save TSKGunGun/af83f9e23b71f468c8b2102a37b3ebc2 to your computer and use it in GitHub Desktop.
def getdata(request):
products = []
for item in Product.objects.all:
product = {
"id" : item.id,
"name" : item.name
}
products.append(product)
jsondata = json.dumps(products, enxure_ascii=False)
return HttpResponse(jsondata, content_type="application/json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment