Skip to content

Instantly share code, notes, and snippets.

@mgerring
Created August 8, 2012 20:37
Show Gist options
  • Save mgerring/3298484 to your computer and use it in GitHub Desktop.
Save mgerring/3298484 to your computer and use it in GitHub Desktop.
Django "replace" filter
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.filter
@stringfilter
def replace(value, arg):
args = arg.split(',')
return value.replace(args[0], args[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment