コード例 #1
0
 def all_difficulties(self, request, *args, **kwargs):
     """
     Get all difficulties list
     """
     qs = trekking_models.DifficultyLevel.objects.all()
     data = api_serializers.DifficultySerializer(qs, many=True, context={'request': request}).data
     return response.Response(data)
コード例 #2
0
 def used_difficulties(self, request, *args, **kwargs):
     """
     Get difficulties used by Trek instances
     """
     data = api_serializers.DifficultySerializer(trekking_models.DifficultyLevel.objects.filter(
         pk__in=trekking_models.Trek.objects.existing().values_list('difficulty_id', flat=True)),
         many=True,
         context={'request': request}).data
     return response.Response(data)