Created
December 4, 2015 08:36
-
-
Save DrMartiner/efabab2682c7d5bfba99 to your computer and use it in GitHub Desktop.
Django's template tag for check owner of entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django import template | |
register = template.Library() | |
@register.assignment_tag(takes_context=True) | |
def is_owner(context, obj, user, field_name='user'): | |
return getattr(obj, field_name, None) == user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment