Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#8292 closed (fixed)

InlineModelAdmin not honoring filter_horizontal

Reported by: David A Krauth Owned by: Brian Rosner
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


One would expect the filter_horizontal / filter_vertical admin options to
function with the InlineModelAdmin classes for generic relationships
in contenttypes.generic.

Considering the code snippet below, I would have expected the nice javascript
dual-picklist interface instead of the plain, single multiselect input.

Sample file:

from django.db import models 
from django.contrib.auth.models import User 
from django.contrib import admin 
from django.contrib.contenttypes import generic 
from django.contrib.contenttypes.models import ContentType 

class GenericDocument(models.Model): 
    title = models.CharField(max_length=100) 
    authors = models.ManyToManyField(User, blank=True) 
    content_type = models.ForeignKey(ContentType) 
    object_id = models.PositiveIntegerField() 
    content_object = generic.GenericForeignKey() 

class Publisher(models.Model): 
    name = models.CharField(max_length=50) 
    articles = generic.GenericRelation(GenericDocument) 

class GenericDocumentInline(generic.GenericStackedInline): 
    model = GenericDocument 
    filter_horizontal = ('authors', ) 

class PublisherAdmin(admin.ModelAdmin): 
    list_display = ('name', ) 
    inlines = [GenericDocumentInline], PublisherAdmin)

Change History (7)

comment:1 Changed 10 years ago by Malcolm Tredinnick

milestone: post-1.0
Triage Stage: UnreviewedSomeday/Maybe

Generic relations are normal fields on a number of levels and expecting them to be drop in replacements everywhere is a little optimistic. So it's not really "one would expect" as much as "one might hope this will work in the future". Postponing this to post-1.0, since it will be fully backwards compatible to add it then and too much work to do so right now.

comment:2 Changed 10 years ago by Malcolm Tredinnick

Component: UncategorizedAdmin interface

comment:3 Changed 10 years ago by Malcolm Tredinnick

milestone: post-1.01.0
Triage Stage: Someday/MaybeAccepted

Hmm ... I see Brian considers this possible in scope for 1.0, so I'll leave it up to him to decide if we can get it done in time. Recategorising on those grounds.

comment:4 Changed 10 years ago by Brian Rosner

Owner: changed from nobody to Brian Rosner
Status: newassigned
Summary: GenericInlineModelAdmin not honoring filter_horizontalInlineModelAdmin not honoring filter_horizontal

It turns out this is bit more than specially generic inlines. It applies to all inlines. Adjusting title to reflect that.

comment:5 Changed 10 years ago by Brian Rosner

Resolution: fixed
Status: assignedclosed

(In [8392]) Fixed #8292 -- Honor filter_horizontal and filter_vertical in inlines correctly. It now adds the right Javascript to handle them when they are the only ones on the page. Thanks dakrauth for the report.

comment:6 Changed 10 years ago by anonymous

I've a similiar model but instead of:

articles = generic.GenericRelation(GenericDocument) 


articles = models.ForeignKey(Document) 

and instead of:

class GenericDocumentInline(generic.GenericStackedInline):


class DocumentInline(admin.StackedInline):

Is there a way to get the javascript dual-picklist interface for authors through a ForeignKey?


comment:7 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top