views:

633

answers:

1

I'm using Photologue in my application, and I really like the ManyToManyField selector that appears in the admin app (two multi-select boxes with arrows for moving items between the selected and non-selected states, along with "Choose All" and "Clear All" options).

I'm using very similar code in my own model, but my ManyToManyField selector just shows up as a normal <select multiple="multiple" ...> field. I can't see anything special in Photologue's admin.py or models.py, and the two apps are running in the same project.

My model:

class Portfolio(models.Model):
    images      = models.ManyToManyField(Photo, related_name='portfolios')
    ...

Relevant model from Photologue:

class Gallery(models.Model):
    ....
    photos = models.ManyToManyField('Photo',
                                    related_name='galleries',
                                    verbose_name=_('photos'),
                                    null=True, blank=True)

Admin from Photologue:

class GalleryAdmin(admin.ModelAdmin):
    list_display = ('title', 'date_added', 'photo_count', 'is_public')
    list_filter = ['date_added', 'is_public']
    date_hierarchy = 'date_added'
    prepopulated_fields = {'title_slug': ('title',)}
    filter_horizontal = ('photos',)

Anyone know what I'm missing? I'll post screenshots if it would help.

Thanks,

Dom

+2  A: 

See django docs for filter_horizontal

a nifty unobtrusive JavaScript "filter" interface instead of the usability-challenged <select multiple> in the admin form.

YHVH
Silly me - that's right there in the question - it just didn't look like it could be the relevant bit of the admin declaration. Thanks!
Dominic Rodger