[Answered ]-Django rest framework custom serializer using foreign key

2👍

✅

Try to use something like:

class CustomSerializer(serializers.Serializer):
    comment = serializers.CharField(required=True)
    mymodel = serializers.ChoiceField(choices=list(MyModel.objects.all().values_list('id', flat=True)))

Leave a comment