﻿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
8319	limit_choices_to does not limit choices on inlined fields with intermediate tables	TrevorFSmith	nobody	"Limiting the choices for a tabular inlined member with an intermediate class does not limit the choices.  In the example below, the select elements in the admin interface include every story, not just stories which have a start date in the past.

For inlined tables where there are thousands of records this can bloat admin page sizes beyond usability.

In models.py:

{{{
class PageContent(models.Model):
	stories = models.ManyToManyField('Story', limit_choices_to={'start_date__lte': datetime.now()}, through='PageContentStoryMembership')

class PageContentStoryMembership(models.Model):
	page_content = models.ForeignKey(PageContent)
	story = models.ForeignKey('Story')
	weight = models.IntegerField(null=False, default=0)
}}}


In admin.py:
{{{
class PageContentStoryMembershipInline(admin.TabularInline):
	model = PageContentStoryMembership

class PageContentAdmin(admin.ModelAdmin):
	inlines = [PageContentStoryMembershipInline]
}}}
"		closed	contrib.admin	dev		wontfix			Unreviewed	0	0	0	0	0	0
