On 1/27/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> I'd suggest that m2m relations use the attribute name, and that we
> introduce an option for ForeignKey that lets you override the o2m name::
>
>      class Article:
>          writer = meta.ForeignKey(Reporter, related_name="articles")
>          sites = meta.ManyToManyField(Site)
>
>      s = Site.objects.get(pk=1)
>      r = Reporter.objects.get(pk=1)
>
>      s.article_set.all()
>      r.articles.all()
>
> That is, if ``related_name`` isn't given then ``OBJECT_set`` is used.

Two quick notes:

1) ManyToManyField will need a related_name argument, not just o2m
fields, so as to handle reverse direction queries (e.g.,
sites.article_set). This may have been implied, but so far all the
disussion and all the examples have been about ForeignKey renaming.

2) I have a minor problem with the _set suffix: to me, _set implies
uniqueness in the returned results, which will not exist unless
.distinct()/distinct=True is used. Either distinct needs to be turned
on by default and disabled by parameter/filter (which I have argued
for in a previous thread), or a suffix that does not imply uniqueness
is required. Possible candidates: _list, _objects

Russ Magee %-)

Reply via email to