Write only, read only fields in django rest framework : <p>I have models like this:</p>

<pre><code>class ModelA(models.Model):
    name = models.CharField()


class ModelB(models.Model):
    f1 = models.CharField()
    model_a = models.ForeignKey(ModelA)
</code></pre>

<p>Serializers:</p>

<pre><code>class ASerializer(serializers.ModelSerializer):
    model_b_ids = serializers.CharField()
    class Meta:
        model = ModelA
        write_only_fields = ('model_b_ids',)
</code></pre>

<p>views:</p>

<pre><code>class AView(CreateModelMixin, GenericViewSet):

    def perform_create(self, serializer): 
        model_b_ids = parse_somehow(serializer.validated_data["model_b_ids"])
        #do something...
</code></pre>

<p>The problem I am getting is the with the "model_b_ids"</p>

<p>The user should submit it while sending post data.</p>

<p>I use it in perform_create to link to related models. </p>

<p>But thats not "real column" in ModelA so when I try to save it is raising exception.</p>

<p>I tried to it pop from validated_data but then again getting error somewhere that cannot read model_b_ids from model. Any idea on using this kind of field correctly ?</p>
