def render_to_response(template_name, dictionary=None, context_instance=None): if isinstance(template_name, (list, tuple)): template = select_template(template_name) else: template = get_template(template_name) dictionary = dictionary or {} if context_instance is None: context_instance = Context(dictionary) else: context_instance.update(dictionary) data = {} [data.update(d) for d in context_instance] data = uni_str(data, encoding=settings.DEFAULT_CHARSET, key_convert=False) return HttpResponse(template.render(**data))
def json_response(data, check=False): encode = settings.DEFAULT_CHARSET if check: if not is_ajax_data(data): raise SimpleAjaxException, 'Return data should be follow the Simple Ajax Data Format' return HttpResponse(simplejson.dumps(uni_str(data, encode)))
def json_response(data, check=False): encode = settings.DEFAULT_CHARSET if check: if not is_ajax_data(data): raise SimpleAjaxException, "Return data should be follow the Simple Ajax Data Format" return HttpResponse(simplejson.dumps(uni_str(data, encode)))