@register.filter
def flagged_with(obj, slug):
 content_type = ContentType.objects.get_for_model(obj)
 flags = Flag.objects.filter(flag_type__slug=slug, content_type=content_type, object_id=obj.pk)
 return (flags.count() != 0)

@ register . filter def flagged_with ( obj , slug ) : content_type = ContentType . objects . get_for_model ( obj ) flags = Flag . objects . filter ( flag_type__slug = slug , content_type = content_type , object_id = obj . pk ) return ( flags . count ( ) != 0 )
returns true of false based on whether the object is flagged one or more times with a particular flag type .