Account Options

  1. Sign in
Google Groups Home
« Groups Home
Message from discussion Many-to-many relationships with additional columns
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Keith-Magee  
View profile  
 More options May 31 2007, 9:32 pm
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Fri, 1 Jun 2007 09:32:38 +0800
Local: Thurs, May 31 2007 9:32 pm
Subject: Re: Many-to-many relationships with additional columns
On 6/1/07, Marty Alchin <gulop...@gamemusic.org> wrote:

> My main reason for bringing it here, however, is to ask if there are
> indeed some previous discussions that I should consider before I go to
> far in my experiments on this subject. Or if I'm just completely off
> my rocker.

You may well be completely off your rocker. I can't claim expertise in
that domain. Mostly because _I'm_ completely off my rocker, most of
the time :-).

However, you're not the first to propose this. In fact, I would doubt
that you are even the tenth. This is a pretty common request.

This is the first time that I've seen a viable mechanism for
distinguishing between queries over properties of the related object
and properties of the relation. Previously, the suggestion has been to
pseudo-add the fields of the relation model to the related classes:

Actor.objects.filter(films__title='Fight Club')
Actor.objects.filter(films__role='Tyler Durden')

Your suggestion seems to be more on the lines of pseudo-adding the
entire relation _model_ to the related classes:

Actor.objects.filter(films__title='Fight Club')
Actor.objects.filter(roles__role='Tyler Durden')

This are still some namespace clash problems, but they're much smaller
than previous suggestions, and the semantic ambiguity (i.e., the
implication of attributes on the related model that aren't actually
there) isn't as pronounced.

To add to your proposal, I would say that the pseudo-attribute should
derive its name from the relation name:

Actor.objects.filter(film_roles__role='Tyler Durden')
Film.objects.filter(actor_roles__role='Tyler Durden')

Specifically, this is avoid problems when you have two m2m relations
with a relation model (not a problem for this scenario, but certainly
conceivable). It also has the advantage of reducing the semantic
ambiguity a little further.

Regarding syntax; Jacob's suggestion is the usual suggested syntax for
proposals in this direction, and I'd have to say I prefer that syntax
to your M2MManager idea. To boot, Jacob's syntax should actually fit
into the existing contribute_to_model framework without too much
difficulty.

So, put me down as a +1, but with Jacob's syntax (or a variation therof).

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.