Saturday, December 31, 2011

Re: Managers of related fields

On Fri, 30 Dec 2011 19:37:54 -0800 (PST)
Daniel Kaplun <> wrote:

> I have Articles that refer to Authors using
> ForeignKey(related_name='articles'). Given an Author author, I'd like
> to be able to use the default manager for author.articles, but I'd
> also like to have author.published_articles, using a custom manager.
> Is this possible?

At the moment, this is not possible, as Django always uses the default
manager when doing the reverse lookup on foreign keys (as well as when
doing lookups in many-to-many relations).

However, there is a patch currently pending review in ticket #3871 [1]
which makes it possible to select which manager instead of the default
manager is used in these lookups.

As I wrote the last iteration of this patch myself, I cannot review it
myself. If you feel confident, please have a look at it and mark it as
"ready for check-in" if you think it is.

Otherwise please head over to <> and
present your use-case there, hopefully finding somebody who can take a
look at the latest progress in ticket #3871.



You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment