开发者

How do I send/get a JSON Object with Django?

开发者 https://www.devze.com 2022-12-15 15:16 出处:网络
I know how to use the JQuery ajax feature to call the \"url view\" of Django. import simplejson as json

I know how to use the JQuery ajax feature to call the "url view" of Django.

import simplejson as json
def the_view(request):
    fruits = {'color':5, 'type': 22}
    jfruit = json.dump(fru开发者_JAVA百科its)

return render_to_response( THE JSON OBJECT!!! ...how? )


return HttpResponse(simplejson.dumps(mydictionary), mimetype="application/json")

see b-list


Or shorter: download http://bitbucket.org/offline/django-annoying/ and write:

@ajax_request 
def the_view(request):
    return {'color':5, 'type': 22}

There are a few such nice tiny things in django-annoying.

0

精彩评论

暂无评论...
验证码 换一张
取 消