def tags_for(cls, model, instance=None, **extra_filters):
 kwargs = (extra_filters or {})
 if (instance is not None):
  kwargs.update({('%s__content_object' % cls.tag_relname()): instance})
  return cls.tag_model().objects.filter(**kwargs)
 kwargs.update({('%s__content_object__isnull' % cls.tag_relname()): False})
 return cls.tag_model().objects.filter(**kwargs).distinct()

def tags_for ( cls , model , instance = None , ** extra_filters ) : kwargs = ( extra_filters or { } ) if ( instance is not None ) : kwargs . update ( { ( '%s__content_object' % cls . tag_relname ( ) ) : instance } ) return cls . tag_model ( ) . objects . filter ( ** kwargs ) kwargs . update ( { ( '%s__content_object__isnull' % cls . tag_relname ( ) ) : False } ) return cls . tag_model ( ) . objects . filter ( ** kwargs ) . distinct ( )
sadly copied from taggit to work around the issue of not being able to use the taggeditembase class that has tag field already defined .