Ejemplo n.º 1
0
def list_related_from(self, request, pk=None):
    # Secondary imports do not incur a cost
    from django.shortcuts import get_object_or_404
    from api_v2.views.rest import CustomTopicSerializer
    from api_v2.models.Topic import Topic
    from rest_framework.response import Response

    parent_queryset = Topic.objects.all()
    item = get_object_or_404(parent_queryset, pk=pk)
    queryset = item.get_active_related_from()
    serializer = CustomTopicSerializer(queryset, many=True)
    return Response(serializer.data)
Ejemplo n.º 2
0
def list_related_to(self, request, pk=None):
    # We load most at runtime because ORM isn't loaded at setup time
    from django.shortcuts import get_object_or_404
    from api_v2.views.rest import CustomTopicSerializer
    from api_v2.models.Topic import Topic
    from rest_framework.response import Response

    parent_queryset = Topic.objects.all()
    item = get_object_or_404(parent_queryset, pk=pk)
    queryset = item.get_active_related_to()
    serializer = CustomTopicSerializer(queryset, many=True)
    return Response(serializer.data)