Reputation: 1607
I want to create a grouped dropdown list in django admin.I could generate a normal drop downlist using "choices = ()".But I need something like this.
--Tools--
Dotnet
Vstudio
-- App --
WMP
Encoder
-- ABC --
a
b
How to achieve this?
Upvotes: 2
Views: 507
Reputation: 22571
This format of choices tuple will do what you need:
items=(
("Animals", (("1","Monkey"), ("2","Turtle"))),
("Aliens", (("3","Zim"), ("4","Tak"))),
)
select=forms.ChoiceField(label="Selection", choices=items)
Upvotes: 6