fix bug of rancher inventory entries - list of all cities

This commit is contained in:
2025-09-08 16:36:42 +03:30
parent 54acba058f
commit 5307a27d20
4 changed files with 26 additions and 12 deletions

View File

@@ -18,12 +18,12 @@ class CityViewSet(ModelViewSet, SoftDeleteMixin): # noqa
def list(self, request, *args, **kwargs):
""" return list of cities by province """
if 'province' in self.request.query_params.keys():
query = self.queryset.filter(province_id=int(request.GET['province']))
else:
query = self.queryset
serializer = self.serializer_class(
self.queryset.filter(
province_id=int(request.GET['province'])
), many=True
)
serializer = self.serializer_class(query, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)