Last active
November 5, 2020 19:41
-
-
Save egitimplus/c1f7edbf8f5a57f0d7834dd5b07721a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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