Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#8292 closed (fixed)

InlineModelAdmin not honoring filter_horizontal

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

Description

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 models.py 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] 

admin.site.register(Publisher, PublisherAdmin)

Change History (7)

comment:1 by Malcolm Tredinnick, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

Component: UncategorizedAdmin interface

comment:3 by Malcolm Tredinnick, 16 years ago

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 by Brian Rosner, 16 years ago

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 by Brian Rosner, 16 years ago

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 by anonymous, 16 years ago

I've a similiar model but instead of:

articles = generic.GenericRelation(GenericDocument) 

I've:

articles = models.ForeignKey(Document) 

and instead of:

class GenericDocumentInline(generic.GenericStackedInline):

I've:

class DocumentInline(admin.StackedInline):

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

Thanks.

comment:7 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

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