Created
November 5, 2020 21:30
-
-
Save egitimplus/9422ac21077b48b6943bec5185f0116f 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 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() | |
content_object = GenericForeignKey() | |
class Sony(models.Model): | |
name = models.CharField(max_length=255) | |
cars = GenericRelation(Car) | |
class Pioneer(models.Model): | |
name = models.CharField(max_length=255) | |
cars = GenericRelation(Car) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment