From b0d3029541c02906d13763aeefd493325cf07b8c Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 23 Jul 2026 21:35:30 -0400 Subject: [PATCH] Switch scrobble API from UUID to pk lookup The ScrobbleViewSet was using lookup_field="uuid" which caused API detail views to fail for scrobbles with NULL UUIDs. Rather than backfilling all NULL UUIDs, switch to pk lookup which is always populated. Changes: - Remove lookup_field="uuid" from ScrobbleViewSet (defaults to pk) - Remove extra_kwargs from ScrobbleSerializer (URL now uses pk) - Update regenerate_share_token action signature to use **kwargs --- vrobbler/apps/scrobbles/api/serializers.py | 3 --- vrobbler/apps/scrobbles/api/views.py | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/vrobbler/apps/scrobbles/api/serializers.py b/vrobbler/apps/scrobbles/api/serializers.py index b44a9d3..efc8a5a 100644 --- a/vrobbler/apps/scrobbles/api/serializers.py +++ b/vrobbler/apps/scrobbles/api/serializers.py @@ -20,9 +20,6 @@ class ScrobbleSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Scrobble fields = "__all__" - extra_kwargs = { - "url": {"view_name": "scrobble-detail", "lookup_field": "uuid"}, - } def update(self, instance, validated_data): note = validated_data.pop("note", None) diff --git a/vrobbler/apps/scrobbles/api/views.py b/vrobbler/apps/scrobbles/api/views.py index d000cf1..575fba1 100644 --- a/vrobbler/apps/scrobbles/api/views.py +++ b/vrobbler/apps/scrobbles/api/views.py @@ -23,13 +23,12 @@ class ScrobbleViewSet(viewsets.ModelViewSet): queryset = Scrobble.objects.all().order_by("-timestamp") serializer_class = ScrobbleSerializer permission_classes = [permissions.IsAuthenticated] - lookup_field = "uuid" def get_queryset(self): return super().get_queryset().filter(user=self.request.user) @action(detail=True, methods=["post"]) - def regenerate_share_token(self, request, uuid=None): + def regenerate_share_token(self, request, **kwargs): scrobble = self.get_object() scrobble.regenerate_share_token() return Response({"share_url": scrobble.get_share_url()})