From dda6b62f378003e7d88b810ee30135543594d825 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Tue, 19 Dec 2023 18:50:00 +0800 Subject: [PATCH] Hotfix for study groups distance --- stude/study_groups/serializers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stude/study_groups/serializers.py b/stude/study_groups/serializers.py index f062c9d..198171e 100644 --- a/stude/study_groups/serializers.py +++ b/stude/study_groups/serializers.py @@ -70,6 +70,11 @@ class StudyGroupDistanceSerializer(serializers.ModelSerializer): fields = '__all__' read_only_fields = ['landmark', 'radius', 'students', 'distance'] + def get_distance(self, obj): + if hasattr(obj, 'distance'): + return obj.distance.km + return 0 + def to_representation(self, instance): representation = super().to_representation(instance) representation['distance'] = 30