This file contains 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 django.db import models | |
from django.contrib.contenttypes.fields import GenericForeignKey | |
from django.contrib.contenttypes.fields import GenericRelation | |
from django.contrib.contenttypes.models import ContentType | |
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) | |
object_id = models.PositiveIntegerField() |
This file contains 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 django.db import models | |
from polymorphic.models import PolymorphicModel | |
class Drive(PolymorphicModel): | |
name = models.CharField(max_length=255) | |
class TwoWheelDrive(Drive): | |
pass |
This file contains 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 django.db import models | |
from polymorphic.models import PolymorphicModel | |
class Audio(PolymorphicModel): | |
name = models.CharField(max_length=255) | |
class Sony(Audio): | |
pass |
This file contains 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 django.db import models | |
class FuelType(models.Model): | |
name = models.CharField(max_length=255) | |
class Car(models.Model): | |
name = models.CharField(max_length=255) |
This file contains 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 django.db import models | |
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
class CarModel(models.Model): | |
name = models.CharField(max_length=255) | |
car = models.ForeignKey(Car, on_delete=models.CASCADE) |
This file contains 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 django.db import models | |
class Car(models.Model): | |
name = models.CharField(max_length=255) | |
class Ceo(models.Model): | |
name = models.CharField(max_length=255, blank=True) | |
car = models.OneToOneField(Car, on_delete=models.CASCADE) |
This file contains 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 | |
This file contains 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
class CarModel(models.Model): | |
name = models.CharField(max_length=255) | |
audio = models.ForeignKey(Audio, on_delete=models.CASCADE, related_name="carmodels", blank=True, null=True) | |
def __str__(self): | |
return self.name |
This file contains 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 Audio(PolymorphicModel): | |
name = models.CharField(max_length=255) | |
def __str__(self): | |
return self.name | |
This file contains 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 django.db import models | |
from django.contrib.contenttypes.fields import GenericForeignKey | |
from django.contrib.contenttypes.fields import GenericRelation | |
from django.contrib.contenttypes.models import ContentType | |
class CarModel(models.Model): | |
name = models.CharField(max_length=255) | |
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) | |
object_id = models.PositiveIntegerField() |
NewerOlder