diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 818ec87..c75c830 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -315,12 +315,26 @@ class ScrobbleListView(LoginRequiredMixin, ListView): if tags_param: tag_list = [t.strip() for t in tags_param.split(",") if t.strip()] if tag_list: - qs = qs.filter(tags__name__in=tag_list).distinct() + from django.contrib.contenttypes.models import ContentType + from taggit.models import TaggedItem + + scrobble_ct = ContentType.objects.get_for_model(Scrobble) + matching_ids = list( + TaggedItem.objects.filter( + content_type=scrobble_ct, + tag__name__in=tag_list, + ).values_list("object_id", flat=True) + ) + qs = qs.filter(id__in=matching_ids).distinct() + else: + tag_list = [] + self.tag_list = tag_list return qs def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) ctx["tags_param"] = self.request.GET.get("tags", "") + ctx["tag_list"] = getattr(self, "tag_list", []) return ctx diff --git a/vrobbler/templates/scrobbles/scrobble_all_list.html b/vrobbler/templates/scrobbles/scrobble_all_list.html index 4ca67f7..7fa585e 100644 --- a/vrobbler/templates/scrobbles/scrobble_all_list.html +++ b/vrobbler/templates/scrobbles/scrobble_all_list.html @@ -5,7 +5,12 @@ {% block content %}
-

All Scrobbles

+
+

All Scrobbles

+ {% if tag_list %} +
Tagged {{ tag_list|join:", " }}
+ {% endif %} +