-
Notifications
You must be signed in to change notification settings - Fork 2
Django
michaelSaunders edited this page Mar 1, 2018
·
5 revisions
from django.http import HttpResponse # HttpResponse is how we send
import json # Converts to json
def [function](request):
# Not actually JSON in this form!
some_json = {
'var1': 'foo',
'var2': 'bar',
}
# Conversion
data = json.dumps(some_json)
# Return JSON and let it know its json
return HttpResponse(data, content_type='application/json')