'Filter for documents with a localization tag on current revision'

def filter_with_localization_tag(self, locale=None, tag=None, tag_name=None):

    query = 'current_revision__localization_tags__%s'
    if tag_name:
        query = {(query % 'name'): tag_name}
    elif tag:
        query = {(query % 'in'): [tag]}
    else:
        query = {(query % 'name__isnull'): False}
    if locale:
        query['locale'] = locale
    return self.filter(**query).distinct()
