import re from django import template register = template.Library() @register.filter def s(value): """ Add an "'s" or "'" where appropriate on proper nouns to to make them posessive """ if re.search(r's$', value): return value + "'" else: return value + "'s"