Multiple Models in Django Rest Framework?
<p>I am using <a href="http://www.django-rest-framework.org/" rel="nofollow noreferrer">Django Rest framework</a>. I want to serialize multiple models and send them as a response. Currently I can send only one model per view (like <code>CartView</code> below sends only Cart object). Following models (unrelated) can be there.</p>
<pre><code>class Ship_address(models.Model):
   ...

class Bill_address(models.Model):
   ...

class Cart(models.Model):
   ...

class Giftwrap(models.Model):
   ...
</code></pre>
<p>I tried using <a href="https://github.com/Axiologue/DjangoRestMultipleModels" rel="nofollow noreferrer">DjangoRestMultipleModels</a>, it works ok but has some limitations. Is there any in-built way? Can't I append to the serializer that's created in the following view?</p>
<pre><code>from rest_framework.views import APIView

class CartView(APIView):
    &quot;&quot;&quot;
    Returns the Details of the cart
    &quot;&quot;&quot;

    def get(self, request, format=None, **kwargs):
        cart = get_cart(request)
        serializer = CartSerializer(cart)
        # Can't I append anything to serializer class like below ??
        # serializer.append(anotherserialzed_object) ??
        return Response(serializer.data)
</code></pre>
<p>I really like DRF. But this use-case (of sending multiple objects) makes me wonder if writing a plain-old Django view will be better suited for such a requirement.</p>