Re: suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
through sounds a little odd to me, as Vacation is the table 'through' which the m2m is made. Shouldn't it be 'in_between' or something the like here? (As Vacation is kind of 'in between' Person and Location) just my 2p. TiNo On Mon, Oct 6, 2008 at 2:44 AM, SliceOf314 <[EMAIL PROTECTED]>wrote: > > > > For example: > > > > class Vacation(Model): > >... > >class Meta: > > through = ('person', 'location') > > > > Yours, > > Russ Magee %-) > > Sounds good to me. Unless someone else has a better suggestion, I > will go ahead and start work on a patch. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
On Mon, Oct 6, 2008 at 1:04 AM, SliceOf314 <[EMAIL PROTECTED]> wrote: > >> My personal preference for that ticket is that the annotation to say >> which foreign keys to use should belong on the model for the >> intermediate table, not adding to the declaration of the connecting >> models. > > That is a very fair point. Therefore, how does the following sound? > > class Vacation(models.Model): ># my suggestion >person = models.ForeignKey(Person, from_m2m='vacations') >location = models.ForeignKey(Location) >date = models.DateField() >travel_agent = models.ForeignKey(Person, > related_name='booked_vacations') I would be inclined to put the setting in the Meta block. Under your proposal, the setting is tied to the key, but the setting isn't really controlling the behaviour of the key - it's controlling the way the model as a whole is interpreted. Having the setting on the key would mean it is exposed on every foreign key - not just the ones in M2M tables. For example: class Vacation(Model): ... class Meta: through = ('person', 'location') Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
> For example: > > class Vacation(Model): > ... > class Meta: > through = ('person', 'location') > > Yours, > Russ Magee %-) Sounds good to me. Unless someone else has a better suggestion, I will go ahead and start work on a patch. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
> My personal preference for that ticket is that the annotation to say > which foreign keys to use should belong on the model for the > intermediate table, not adding to the declaration of the connecting > models. That is a very fair point. Therefore, how does the following sound? 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): # my suggestion person = models.ForeignKey(Person, from_m2m='vacations') location = models.ForeignKey(Location) date = models.DateField() travel_agent = models.ForeignKey(Person, related_name='booked_vacations') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
On Sat, 2008-10-04 at 10:16 -0700, SliceOf314 wrote: [...] > How does the following syntax sound? > > If people like it, or have better suggestions, I could write the > patch. > > vacations = models.ManyToManyField('Location', through=('person, > 'Vacation','location'), blank=True) > > This should give enough information to specify the exact attribute > path for the m2m relationship. If the intermediary table doesn't have > multiple keys, then the existing syntax should suffice. My personal preference for that ticket is that the annotation to say which foreign keys to use should belong on the model for the intermediate table, not adding to the declaration of the connecting models. This seems more self-contained. For example, if you add an extra column to the intermediate model you only have to update that model, not hunt down and find the connecting models (which you may not necessarily have permission to alter the code for in any case). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
suggestion for ticket #8618, Many-to-many intermediary with multiple foreign keys
Given the example code in the ticket: 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') How does the following syntax sound? If people like it, or have better suggestions, I could write the patch. vacations = models.ManyToManyField('Location', through=('person, 'Vacation','location'), blank=True) This should give enough information to specify the exact attribute path for the m2m relationship. If the intermediary table doesn't have multiple keys, then the existing syntax should suffice. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---