From 39144a209e6efcac43719dc416004dfdb1d55909 Mon Sep 17 00:00:00 2001 From: d0c Date: Thu, 27 Apr 2023 00:07:26 +0200 Subject: [PATCH] search soc --- suitablephones/models.py | 2 +- suitablephones/views.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/suitablephones/models.py b/suitablephones/models.py index c289a33..db0d388 100644 --- a/suitablephones/models.py +++ b/suitablephones/models.py @@ -34,7 +34,7 @@ class Screen(models.Model): return f"{str(self.size_in)} - {str(self.density)} - {str(self.technology)}" class Device(models.Model): - architecture = models.JSONField(default=dict) + #architecture = models.JSONField(default=dict) #battery = models.JSONField(default=dict) #before_install = models.JSONField(default=dict, null=True) # dict or str bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE, null=True) diff --git a/suitablephones/views.py b/suitablephones/views.py index 254efe0..8b208e9 100644 --- a/suitablephones/views.py +++ b/suitablephones/views.py @@ -39,20 +39,23 @@ class DeviceViewSet(viewsets.ModelViewSet): size_in = self.request.query_params.get('size_in') resolution = self.request.query_params.get('resolution') screen_type = self.request.query_params.get('screen_type') + soc = self.request.query_params.get('soc') #maintainers = self.request.query_params.getlist('maintainers') version = self.request.query_params.get('version') if name: self.queryset = self.queryset.filter(name__icontains=name) if megapixel: self.queryset = self.queryset.filter(cameras__megapixel__gt=Decimal(megapixel)) - if version: - self.queryset = self.queryset.filter(versions__icontains=version) if size_in: self.queryset = self.queryset.filter(screen__size_in__lt=Decimal(size_in)) if resolution: self.queryset = self.queryset.filter(screen__resolution__icontains=resolution) if screen_type: self.queryset = self.queryset.filter(screen__technology__icontains=screen_type) + if soc: + self.queryset = self.queryset.filter(soc__icontains=soc) + if version: + self.queryset = self.queryset.filter(versions__icontains=version) #if maintainers: self.queryset = self.queryset.filter(maintainers__len__gt=0) return self.queryset