简体   繁体   中英

How can I apply an action to multiple items in a list_filter, without having to do them individually, one after the other?

Say i have in django admin,

list_filters = ['car_number']

It will give me a list of the car numbers that are in the model for me to choose from one by one.

What I want to do is apply an action to multiple 'car_number's but before I can do that i have to have them visually listed so that I can click the little check box, go to my list of actions and apply the action.

If you have car instances with car_number fields populated from 1-10 and you choose number 6 from the filter list, any car with that number will show up and after it does you can apply an action. But I want to apply an action to both number 6 & 4 without having to do them individually one after the other. How can I go about this? is there a way to search for them both at the same time? a way to do multiple sections in the filter list?

Just in case it makes a difference, I am running django suit on top of admin

import numpy
cars = numpy.array([1,2,3,4,5,6]])
map(action,cars[:,[4,6]])

maybe?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM