1

I would like to set the value of a field in multiple rows of Django Admin.

For example if I had database of books with shelf locations I might move several books to another shelf. I need a way, within Django Admin, to input the new shelf location and update the multiple selected items.

I have seen that you can run Admin Actions but I need an easy way to input a value into the action.

1 Answers1

0

You can do this with admin actions, by providing an intermediate page with a form to input the value you want:

https://docs.djangoproject.com/en/1.8/ref/contrib/admin/actions/#actions-that-provide-intermediate-pages

Alternatively you could use some client-side scripting to collect the value from the user and append it to the querystring (or as an extra input field int he POST data) when submitting the admin action form.

Your admin action function receives the request object as an argument so has access to the extra GET/POST fields:

https://docs.djangoproject.com/en/1.8/ref/contrib/admin/actions/#adding-actions-to-the-modeladmin

Anentropic
  • 32,188
  • 12
  • 99
  • 147
  • This is what I had feared it seems like overkill to create a new seperate page to input one value of text. No way to get a popup input field that sends to the admin action? –  Jul 20 '15 at 12:33
  • in that case you need to do some client-side hacking, see updated answer – Anentropic Jul 20 '15 at 13:27