From 73bf4bd58aaa2f8de84364c5e32812c8e3d3a0a0 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Tue, 6 May 2025 21:54:23 +0100 Subject: [PATCH] scan-data-labels: Don't return records with empty label --- api/products/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/products/views.py b/api/products/views.py index f880055..623db74 100644 --- a/api/products/views.py +++ b/api/products/views.py @@ -1928,7 +1928,9 @@ class ScanDataLabelsView(BaseView): def get(self, request): ret = [] - for x in ScanData.objects.all().order_by('pk').values('id', 'labels', 'image', 'code'): + for x in ScanData.objects.all().filter(labels__isnull=False).order_by('pk').values('id', 'labels', 'image', 'code'): + if not x.get('labels'): + continue ret.append({ 'id': x['id'], 'labels': x.get('labels'),