Skip to content

Instantly share code, notes, and snippets.

View arshaver's full-sized avatar

Anthony Shaver arshaver

View GitHub Profile
@arshaver
arshaver / jsonp_decorator.py
Created January 9, 2012 00:28 — forked from sivy/jsonp_decorator.py
a jsonp view decorator for Django
def jsonp(f):
"""Wrap a json response in a callback, and set the mimetype (Content-Type) header accordingly
(will wrap in text/javascript if there is a callback). If the "callback" or "jsonp" paramters
are provided, will wrap the json output in callback({thejson})
Usage:
@jsonp
def my_json_view(request):
d = { 'key': 'value' }