Last active
April 22, 2019 13:19
-
-
Save specialunderwear/73506a597c64ab58ce2e151d9407e028 to your computer and use it in GitHub Desktop.
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 Bar(models.Model): | |
spam = models.EmailField() | |
class Foo(models.Model): | |
bars = models.ManyToManyField(Bar, through='ThroughFooBars') | |
class ThroughFooBars(models.Model): | |
foo = models.ForeignKey(Foo, models.DO_NOTHING) | |
bar = models.ForeignKey(Bar, models.DO_NOTHING) | |
order = models.PositiveIntegerField(default=0) | |
class Meta: | |
db_table = 'through_foo_bars' | |
unique_together = (('foo', 'bar'),) | |
ordering = ('order',) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment