#28476: Difficulty getting filter_horizontal to extend to the InlineModelAdmin object in admin? -------------------------------------+------------------------------------- Reporter: bbiney1 | Owner: nobody Type: Bug | Status: new Component: | Version: 1.11 contrib.admin | Keywords: inlinemodeladmin Severity: Normal | admin Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- 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,] }}} -- Ticket URL: <https://code.djangoproject.com/ticket/28476> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.aa38ecaa09b23e465ef5402a65d65549%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.