admin panel adding left-right panel

52 views
Skip to first unread message

ledzgio

unread,
Jul 2, 2012, 9:26:07 AM7/2/12
to django...@googlegroups.com
In default admin panel, under group permissions, I saw a double panels where I can add an element from the left list panel to the right one instead of selecting multiple elements by holding CTRL. I would like to have this panel implementation in my admin with my models, how can I do that?

thanks

Sunny Nanda

unread,
Jul 2, 2012, 11:28:48 AM7/2/12
to django...@googlegroups.com
You can specify a 'filter-horizontal' tuple in the admin model declaration: 

-Sandeep

ledzgio

unread,
Jul 2, 2012, 2:17:42 PM7/2/12
to django...@googlegroups.com
Thanks very much for your response, really appreciated. But I am a noob and I don't know how to do this :)
Could you please provide a simple example?

and more, how can I populate this field in admin with the table data?

thanks again
Message has been deleted

ledzgio

unread,
Jul 2, 2012, 3:48:50 PM7/2/12
to django...@googlegroups.com
Ok I managed to get filter_vertical working, thanks.

Now how can I populate the filter_vertical panel in admin with the data in the table?

A piece of my model is:
class Position(models.Model):
    POSITIONS = (('GK', 'Goalkeeper'), ('DFC', 'Defender Central'), ('SW', 'Sweeper'),
                 ('DFL', 'Defender Left'), ('DFR', 'Defender Right'),
                 ('WBL', 'Wing Back Left'), ('WBR', 'Wing Back Right'),
                 ('DM', 'Defender Midfielder'), ('MR', 'Midfielder Right'), ('ML', 'Midfielder Left'),
                 ('MC', 'Midfielder Center'), ('AMC', 'Attacking Midfielder Center'), ('AML', 'Attacking Midfielder Left'),
                 ('MC', 'Attacking Midfielder Right'), ('ST', 'Striker'))
    position_name = models.CharField(max_length=

50, choices=POSITIONS)
    def __unicode__(self):
        return self.position_name

class Player(models.Model):
        ........
        ........
        role = models.ManyToManyField(Position)
       .........

in admin:
class PlayerAdmin(admin.ModelAdmin):
        .......
        .......
        filter_vertical = ('role')

I want that in PlayerAdmin I have the choices POSITIONS values listed.

What I should have is something like the image at the following link, with the choices POSITIONS listed on the left panel.

image
Reply all
Reply to author
Forward
0 new messages