def allowed_access(self, request, *args, **kwargs): instance = self.get_object() qs = instance.allowed_access.all() serializer = AccessTypeSerializer(qs, context={'request': request}, many=True) #serializer = ActivitySerializer(qs) return Response(serializer.data)
class VehicleSerializer(serializers.ModelSerializer): access_type = AccessTypeSerializer() rego_expiry = serializers.DateField(format="%d/%m/%Y") class Meta: model = Vehicle fields = ('id', 'capacity', 'rego', 'license', 'access_type', 'rego_expiry', 'proposal')
class ProposalParkAccessSerializer(serializers.ModelSerializer): access_type=AccessTypeSerializer() class Meta: model = ProposalParkAccess fields = '__all__'