Skip to content

Instantly share code, notes, and snippets.

@egitimplus
Last active November 5, 2020 19:41
Show Gist options
  • Save egitimplus/c1f7edbf8f5a57f0d7834dd5b07721a3 to your computer and use it in GitHub Desktop.
Save egitimplus/c1f7edbf8f5a57f0d7834dd5b07721a3 to your computer and use it in GitHub Desktop.
from polymorphic.models import PolymorphicModel
class Drive(PolymorphicModel):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class TwoWheelDrive(Drive):
pass
class FourWheelDrive(Drive):
pass
class CarModel(models.Model):
name = models.CharField(max_length=255)
drive = models.ManyToManyField(Drive, related_name="carmodels")
def __str__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment