def all_networks(self, request, *args, **kwargs): """ Get all networks list """ data = api_serializers.TrekNetworkSerializer(trekking_models.TrekNetwork.objects.all(), many=True, context={'request': request}).data return response.Response(data)
def used_networks(self, request, *args, **kwargs): """ Get networks used by Trek instances """ data = api_serializers.TrekNetworkSerializer(trekking_models.TrekNetwork.objects.filter( pk__in=trekking_models.Trek.objects.existing().values_list('networks', flat=True)), many=True, context={'request': request}).data return response.Response(data)