MCPcopy
hub / github.com/django/django / render_to_response

Method render_to_response

django/views/i18n.py:214–231  ·  view source on GitHub ↗
(self, context, **response_kwargs)

Source from the content-addressed store, hash-verified

212 }
213
214 def render_to_response(self, context, **response_kwargs):
215 def indent(s):
216 return s.replace("\n", "\n ")
217
218 with builtin_template_path("i18n_catalog.js").open(encoding="utf-8") as fh:
219 template = Engine().from_string(fh.read())
220 context["catalog_str"] = (
221 indent(json.dumps(context["catalog"], sort_keys=True, indent=2))
222 if context["catalog"]
223 else None
224 )
225 context["formats_str"] = indent(
226 json.dumps(context["formats"], sort_keys=True, indent=2)
227 )
228
229 return HttpResponse(
230 template.render(Context(context)), 'text/javascript; charset="utf-8"'
231 )
232
233
234class JSONCatalog(JavaScriptCatalog):

Callers 1

getMethod · 0.95

Calls 9

EngineClass · 0.90
HttpResponseClass · 0.90
ContextClass · 0.90
builtin_template_pathFunction · 0.70
openMethod · 0.45
from_stringMethod · 0.45
readMethod · 0.45
dumpsMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected