home / django_tickets / tickets

tickets: 8618

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
8618 2008-08-27 19:17:24 2014-08-11 14:21:18 2022-03-06 03:42:43.846234 Accepted closed Database layer (models, ORM) New feature Normal dev duplicate Many-to-many intermediary tables can't have multiple foreign keys to source/target models The following schema: {{{ from django.db import models class Person(models.Model): name = models.CharField(max_length=100) vacations = models.ManyToManyField('Location', through='Vacation', blank=True) class Location(models.Model): city = models.CharField(max_length=100) country = models.CharField(max_length=100) class Vacation(models.Model): person = models.ForeignKey(Person) location = models.ForeignKey(Location) date = models.DateField() travel_agent = models.ForeignKey(Person, related_name='booked_vacations') }}} doesn't pass validation because "Intermediary model Vacation has more than one foreign key to Person, which is ambiguous and is not permitted." It looks to me like the only reason for this error is because django doesn't have a way to specify which foreign keys on the intermediary model are relevant (or that there is no default behavior specified). There's obviously more than one way around this, and probably someone can come up with a nicer example schema than I did. The simplest thing would be to get rid of that validation check, which (i think) would cause django to use the first key found for each model. nobody coda m2m intermediary validation 0 0 0 0 0 0
Powered by Datasette · Queries took 1.613ms