#8618: Many-to-many intermediary tables can't have multiple foreign keys to
source/target models
-----------------------------------------+----------------------------------
Reporter: coda | Owner: nobody
Status: new | Milestone:
Component: Database wrapper | Version: SVN
Keywords: m2m intermediary validation | Stage: Unreviewed
Has_patch: 0 |
-----------------------------------------+----------------------------------
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.
--
Ticket URL: <http://code.djangoproject.com/ticket/8618>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---