def render_json(self, request, context, template_name): context = simplify_value(context) resolved = resolve(request.path) context['view_name'] = '%s:%s' % (':'.join( resolved.namespaces), resolved.url_name) return HttpResponse(simplejson.dumps(context), mimetype="application/json")
def render_json(self, request, context, template_name): context = simplify_value(context) resolved = resolve(request.path) context['view_name'] = '%s:%s' % ( self.conf.application_name.split('.')[-1], resolved.url_name) # Include CSRF token, as templates don't get rendered csrf_token is # never called which breaks CSRF for apps written against the JSON API get_token(request) return HttpResponse(simplejson.dumps(context), mimetype="application/json")
def render_yaml(self, request, context, template_name): import yaml context = simplify_value(context) return HttpResponse(yaml.safe_dump(context), mimetype="application/x-yaml")
def render_xml(self, request, context, template_name): context = simplify_value(context) return HttpResponse( etree.tostring(serialize_to_xml(context), encoding='UTF-8'), mimetype="application/xml")
def render_js(self, request, context, template_name): callback = request.GET.get('callback', request.GET.get('jsonp', 'callback')) content = simplejson.dumps(simplify_value(context)) content = "%s(%s);" % (callback, content) return HttpResponse(content, mimetype="application/javascript")
def render_json(self, request, context, template_name): context = simplify_value(context) return HttpResponse(simplejson.dumps(context), mimetype="application/json")
def render_json(self, request, context, template_name): context = simplify_value(context) resolved = resolve(request.path) context['view_name'] = '%s:%s' % (':'.join(resolved.namespaces), resolved.url_name) return HttpResponse(simplejson.dumps(context), mimetype="application/json")
def render_xml(self, request, context, template_name): context = simplify_value(context) return HttpResponse(etree.tostring(serialize_to_xml(context), encoding='UTF-8'), mimetype="application/xml")