Skip to content

Instantly share code, notes, and snippets.

@akobashikawa
Created May 15, 2015 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akobashikawa/7569706182654ae5f00f to your computer and use it in GitHub Desktop.
Save akobashikawa/7569706182654ae5f00f to your computer and use it in GitHub Desktop.
Django tag to publish context value in templates
# Use: {% set_context_value "varname" value %}
@register.simple_tag(takes_context=True)
def set_context_value(context, name, value):
context[name] = value
return ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment