﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26397	Use custom managers on Foreign Key	Vlad Lep	nobody	"Hi,

My case is similar as the one described in ticket #3871  but that one was solved in a way that does not cover my problem:
I have a Category model that has a boolean flag is_active. Two managers are on this model, the default one excludes categories that are inactive (is_active=False) while a second managers including_inactive retrieves all categories. 

I have also an Article that has a foreign key to a Category model. On all the other models I would like to see only the active categories but on the Article FK, i would like to be able to choose from inactive ones also. To do, the nicest way would be to just have an option:
  
{{{
  class Article(models.Model):
       models.ForeignKey(Category, manager=Category.including_inactive)

}}}

Ticket #3871 created this solution but that is not really the same: https://docs.djangoproject.com/en/1.8/topics/db/queries/#using-custom-reverse-manager

I also find this solution but that would change it on all the related mangers, while I want it only on one:
http://stackoverflow.com/questions/7489635/how-to-use-custom-manager-with-related-objects

To hack around, it I found this solution but would be nice if this would be included in django if it you consider it would be useful:
http://www.hoboes.com/Mimsy/hacks/custom-managers-django-foreignkeys/

Best,
Vlad"	New feature	closed	Database layer (models, ORM)	1.8	Normal	duplicate			Unreviewed	0	0	0	0	0	0
