Hi there - 

I currently need a fairly simple API except for the fact that I'd like to 
host multiple sites on one server (using a variation on the Django Sites 
framework).

When you get a list of objects, it should only be the ones in that Site 
(taken from the host part of the URL).  When you create one, it should be 
created in the right Site, etc. 

Anyone recommend the neatest way of doing this?  I've started to override 
each of the methods on the viewset for my 'Location' class, but thought 
there might be a Right Way...  :-)

Any recommendations much appreciated, before I get too stuck in...
Quentin

class LocationViewSet(viewsets.ModelViewSet):
    ...
    def list(self, request, format=None):
        queryset = Location.objects.filter(site=request.site)
        ser_class = LocationSerializer
        serializer = ser_class(queryset, many=True, context={'request': 
request})
        return Response(serializer.data)

etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to