МП
Size: a a a
МП
AL
А
V
b
V
b
VK
V
b
b
РП
SerializerMethodField
b
РП
РП
def list(self, request, *args, **kwargs):
response = super(OversView, self).list(request, args, kwargs)
response.data['results'] = sorted(
response.data['results'], key=lambda k: k['count'], reverse=True)
return response
РП
b
РП
b
РП
class VacancySerializer(ModelSerializer):
count = serializers.SerializerMethodField()
def get_count(self, obj):
count = Vacancy.objects.filter(city__in=[obj], active=True).count()
return count