title: serializing foreing key variable in update method
body: <p>I'm trying to override the update method of a serializer. This serializer have a field 'gear' which is a foreing key of the Trawl table. But when I try to save the updated instance in update method, I get the error:</p>
  <blockquote>
  <p>ValueError: Cannot assign &quot;2&quot;: &quot;Haul.gear&quot; must be a &quot;Trawl&quot;
  instance</p>
  </blockquote>
  <p>This is the serializer:</p>
  <pre><code> class HaulTrawlSerializer(serializers.ModelSerializer):
   
       gear = serializers.IntegerField()
   
       class Meta:
           model = Haul
           fields = ['id', 'haul', 'gear', 'valid', ]
  
       def update(self, instance, validated_data):
   
           if validated_data:
               for attr, value in validated_data.items():
                   print(attr, value)
                   setattr(instance, attr, value)
  
               instance.save()
   
           return instance
  </code></pre>
  <p>So I try to convert Haul.gear to a Trawl instance changing the update method:</p>
  <pre><code>     def update(self, instance, validated_data):
  
           instance.gear = Trawl.objects.get(pk=validated_data.pop('gear'))
   
           if validated_data:
               for attr, value in validated_data.items():
                   print(attr, value)
                   setattr(instance, attr, value)
  
               instance.save()
   
           return instance
  </code></pre>
  <p>And then, the error</p>
  <blockquote>
  <p>TypeError: int() argument must be a string, a bytes-like object or a
  number, not 'Trawl'</p>
  </blockquote>
  <p>is thrown and I don't understand it. Why first ask for a Trawl instance, but after ask for a int?</p>