How do I make a Django Admin drop down list have a dependency on a search box?
I currently have a workable Django admin on the left mockup below but want it to look and function like the one on the right.
Basically, I'm creating custo开发者_高级运维mized menu list every now and then but I have 1000 menu items to choose from. The pain is manually finding the item I want by scrolling through about 1000 items. I'm thinking of associating a search box next to each drop down menu where I can type the item I want and the drop drop list will automatically show me any matches to my keywords.
Is the above easily done with the current Django Admin or does that involve some more customized code from my part? I could use a horizontal filter but I need that sort order field which is associated with each row.
It sounds like you are describing the raw_id_fields option of admin...
class YourAdmin(admin.ModelAdmin):
raw_id_fields = ('field1','field2')
easiest way - write your own custom widget and connect search field and drop down through js code.
But i think that you trying to get more than contrib.admin can give. contrib.admin is good developer tool, but if you need good custom interface - you should create it yourself.
精彩评论