擅长:python、mysql、java
<p>我提出的解决方案是重写序列化程序的\u representation()方法:</p>
<pre><code>def to_representation(self, instance):
ret = super(BlastEventSerializer, self).to_representation(instance)
instrument_id = self.context['request'].query_params.get('instrument_id')
if instrument_id:
ret['size'] = 77 # some custom calculations
return ret
</code></pre>