Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2014 17:26
Show Gist options
  • Save anonymous/10404375 to your computer and use it in GitHub Desktop.
Save anonymous/10404375 to your computer and use it in GitHub Desktop.
class MyModel(PolymorphicModel):
@property
def driver(self):
if self.is_departure: return self.delivery_driver
else: return self.collection_driver
@driver.setter
def driver(self, value):
if self.is_departure: self.delivery_driver = value
else self.collection_driver = value
class MyModelSerializer(serializers.ModelSerializer):
driver = UserSerializer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment