diff --git a/apps/enp/serializers.py b/apps/enp/serializers.py index 27b9a471..e1359156 100644 --- a/apps/enp/serializers.py +++ b/apps/enp/serializers.py @@ -163,6 +163,8 @@ class EnvDataExportSerializer(serializers.Serializer): class CarWashSerializer(CustomModelSerializer): + station_name = serializers.CharField(source='station.name', read_only=True) + class Meta: model = CarWash fields = "__all__" diff --git a/apps/enp/views.py b/apps/enp/views.py index fa80064a..c8cdb3b7 100644 --- a/apps/enp/views.py +++ b/apps/enp/views.py @@ -138,6 +138,7 @@ class CarWashViewSet(ListModelMixin, CustomGenericViewSet): perms_map = {'get': '*'} queryset = CarWash.objects.all() serializer_class = CarWashSerializer + select_related_fields = ['station'] filterset_fields = { "station": ['exact'], "start_time": ['exact', 'gte', 'lte', 'year', 'month', 'day'],