﻿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
28476	Difficulty getting filter_horizontal to extend to the InlineModelAdmin object in admin?	bbiney1@swarthmore.edu	nobody	"I'm kind of surprised at how I haven't been able to find an example or very much discussion of someone applying filter_horizontal to an InlineModelAdmin object. I did see one report from 9 or so years ago of someone acknowledging a bug wit the feature, but that was resolved. I'm posting this ticket to simply ask again because at this point i really don't know how I'm supposed to use this really helpful feature.

For full context, I have two models. One called Statement and one called Keyword. Each Keyword object has a m2m with a Statement, so a statement can have many keywords. I would like to, in the admin change page for statements, give the user the ability to add or remove keywords from a statement. So inlines are the obvious answer.

But there are a lot of Keyword objects, so the drop down scrollable menu that is automatically rendered by django isn't usable for me. Filter_horizontal would be ideal.

But I've been trying to get this to work and it seems like I just can't find the syntax to do it. Here's my code block for both of the models and their presentation in admin.


{{{
@python_2_unicode_compatible
class Keyword(models.Model):
    word      = models.CharField(max_length=200)
    statement = models.ManyToManyField(Statement)
    def __str__(self):
        return self.word

@python_2_unicode_compatible
class Statement(models.Model):
    statement_id = models.CharField(max_length=200)
    title = models.CharField(max_length=200)
    issue_date = models.DateField(""Issue-Date"")
    author = models.ForeignKey(Person)
    released_by = models.ForeignKey(Organization)
    keywords = models.ManyToManyField('KeywordInContext')

class KeywordInline(admin.TabularInline):
    model = Keyword.statement.through

class KeywordAdmin(admin.ModelAdmin):
    filter_horizontal = ('statement',)

class StatementAdmin(admin.ModelAdmin):
    inlines = [ KeywordInline,]

}}}
"	Bug	closed	contrib.admin	1.11	Normal	invalid	inlinemodeladmin admin	bbiney1@swarthmore.edu	Accepted	0	0	0	0	0	0
