tickets: 8319
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8319 | 2008-08-14 17:53:54 | 2009-02-25 20:06:10 | 2022-03-06 03:41:56.355261 | Unreviewed | closed | contrib.admin | dev | wontfix | limit_choices_to does not limit choices on inlined fields with intermediate tables | 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] }}} | nobody | TrevorFSmith | 0 | 0 | 0 | 0 | 0 | 0 |