I am using the Django rest 2.3 platform. I have a class like this
class Quiz(): fields..
As you can see, I have a user results manager, so Result.objects.filter() will only return results that have save_once set to True
Now my serializers look like this:
class ResultSerializer(serializers.ModelSerializer): fields... class QuizSerializer(serializers.ModelSerializer): results = ResultSerializer(many=True, required=False, source='result_set')
Now, if I serialized my quiz, it will only return results for which saved_once set to True . But for a specific use case, I want the serializer to return all objects. I read that I can do this by passing the queryset parameter http://www.django-rest-framework.org/api-guide/relations/ in the section (further section). However, when I try to do this
results = ResultSerializer(many=True, required=False, source='result_set', queryset= Result.objects.filter( saved_once__in=[True, False]))
I get TypeError: __init__() got an unexpected keyword argument 'queryset' And, looking at the DRF source code (in my version at least), it does not accept the request argument.
Looking for some guidance on this to see if this is possible ... thanks!
source share