def _analytics_script(self, tags, caller): # TODO: filter by current site # when m2m relations will be ready) #code_pieces = Analytics.query().on_site() code_pieces = Analytics.query(); if tags: names = tags.split(',') code_pieces = code_pieces.filter(name__in=names) code = code_pieces.values_list('code', flat=True) return "\r\n".join(code)