Skip to content

Instantly share code, notes, and snippets.

@akshar-raaj
Created May 7, 2019 10:48
Show Gist options
  • Select an option

  • Save akshar-raaj/7c8257044f5891443b850e84f667af42 to your computer and use it in GitHub Desktop.

Select an option

Save akshar-raaj/7c8257044f5891443b850e84f667af42 to your computer and use it in GitHub Desktop.
Serializer source
class QuestionSerializer(serializers.ModelSerializer):
choices = serializers.SlugRelatedField(slug_field='choice_text', read_only=True, many=True, source='choice_set')
class Meta:
model = Question
fields = '__all__'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment