MCPcopy
hub / github.com/django/django / nonce_attr

Function nonce_attr

django/utils/csp.py:84–90  ·  view source on GitHub ↗
(context, media=None)

Source from the content-addressed store, hash-verified

82
83
84def nonce_attr(context, media=None):
85 nonce = context.get(CONTEXT_KEY)
86 if media:
87 return media.render(attrs={"nonce": nonce} if nonce is not None else None)
88 if nonce is None:
89 return ""
90 return format_html('nonce="{}"', nonce)
91
92
93def generate_nonce():

Callers

nothing calls this directly

Calls 3

format_htmlFunction · 0.90
getMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected