try:
import json
except:
from simplejson as json
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
def generate_json(request):
#it can be a dictionary too, anything supported by simplejson
somelist=[]
#do something here, to fill in somelist
encoded=json.dumps(somelist)
response['content-disposition'] = 'attachment; filename=properties.json'
response=HttpResponse(encoded,mimetype="application/json")
return response
So there it is...
p.s I need a way to display source code properly on my blog, idea?
No comments:
Post a Comment