Call method once to set multiple fields in Django Rest Framework serializer
<p>How can I call the same method one time to set multiple fields with a Django Rest Framework serializer? This is what I do now but this clearly calls the method two times. How can I limit it to only be called once?</p>

<pre><code>class MyModel(models.Model):
    def GetTwoValues(self):
        foo = []
        bar = []

        # expensive operation

        return foo, bar

class MyModelSerializer(serializers.HyperlinkedModelSerializer):
    foo = serializers.SerializerMethodField()
    bar = serializers.SerializerMethodField()

    def get_foo(self, obj):
        foo, _ = obj.GetTwoValues()
        return foo

    def get_bar(self, obj):
        _, bar = obj.GetTwoValues()
        return bar

    class Meta:
        model = MyModel
        fields = ('FirstValue', 'SecondValue',)
</code></pre>