-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError when ParentalManyToManyField is specified with a through model #83
Comments
Is this feature really needed, or can the same thing be done with a ParentalKey on the through model (i.e. the way we 'faked' M2M relationships before |
This feature is really useful for projects with models that were implemented before modelcluster/Wagtail introduced M2M support. So models like class BarToFoo(models.Model):
foo = models.ForeignKey('appname.FooModel', blank=True, null=True)
page = models.ParentalKey('BarPage', related_name='something') can be modified to become: class BarToFoo(models.Model):
foo = models.ForeignKey('appname.FooModel', blank=True, null=True)
page = models.ForeignKey('BarPage', related_name='+') Then you just need to add It also allows developers to add additional data into through models. |
A through model is a requirement when you want to record additional information about the relationship. I need to record a rich text description per many-to-many relationship, the (source, target) tuples must be unique, and I need to put minimum and maximum limits on the relationship (each source needs to have at least 1, at most 8 such relationships recorded). I guess I can achieve this with an inline panel and a full-blown model with a |
The syntax for Also it looks like Django just merged better support for updating m2m relationships that have an intermediary model as well: django/django#8981. So for the example in the ticket description you will be able to use |
Django throws
AttributeError
whenParentalManyToManyField
is specified with a through model.Demo with Wagtail:
Traceback:
Django==1.10.7
wagtail==1.11.1
The text was updated successfully, but these errors were encountered: