def json_api(request, model, function): vars = dict((str(k),v) for k, v in request.REQUEST.iteritems()) vars.update(dict((str(k), v) for k, v in request.FILES.iteritems())) try: response = HttpResponse(json.dumps(cereal.call(model, function, **vars), default=to_json), mimetype='application/json') if settings.DEBUG: response['Cache-Control'] = 'no-cache' except KeyError: if not settings.DEBUG: raise Http404 raise return response
def render(self, context): context[self.variable] = cereal.call(self.model, self.function, **dict((k, v.resolve(context)) for k,v in self.kwargs.iteritems())) return ''