A custom template filter will help:
from django import template
register = template.Library()
@register.filter(name='private')
def private(obj, attribute):
return getattr(obj, attribute)
You can use it as follows:
{{ value|private:'_id' }}
source
share