Skip to content

Instantly share code, notes, and snippets.

@egitimplus
Created November 5, 2020 21:26
Show Gist options
  • Select an option

  • Save egitimplus/7708b2034552507cd8b0a8dff8ca6fd3 to your computer and use it in GitHub Desktop.

Select an option

Save egitimplus/7708b2034552507cd8b0a8dff8ca6fd3 to your computer and use it in GitHub Desktop.
from django.db import models
from polymorphic.models import PolymorphicModel
class Drive(PolymorphicModel):
name = models.CharField(max_length=255)
class TwoWheelDrive(Drive):
pass
class FourWheelDrive(Drive):
pass
class Car(models.Model):
name = models.CharField(max_length=255)
drive = models.ManyToManyField(Drive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment