Django Admin Action With Intermediate Page: Not Getting Info Back
I'm trying to create an admin action that adds a custom time delta to some date. The time delta will be read from a input in the intermediate page. After confirming it, I will appl
Solution 1:
Probably too late to help OP, but I came across this question when having the same issue and it was not immediately obvious looking elsewhere what was going on.
When the changelist_view
is processed (the view we are POST
ing to) it looks in request.POST
for a specific key: _selected_action
which is defined in django.contrib.admin.helpers
as ACTION_CHECKBOX_NAME
. I used the delete action that is built into the admin for reference, and it uses it this way in the template:
{% for obj in queryset %}
<inputtype="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}">
{% endfor %}
then in your context you just need to:
context = {
'queryset': queryset, # method param'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
}
Now your method gets called again when you POST
your form, and you can detect/handle the POST
as you're trying to do here. (You want to return None
from the block that handles your POST
data so the view knows to go back to the list view.)
Post a Comment for "Django Admin Action With Intermediate Page: Not Getting Info Back"