Open WarToaster opened 7 years ago
I don't think that's something that can be handled with django-object-actions
. You could store Admin form state in localStorage
.
Thanks for the work on it, but it doesn't quite seem fixed. The newest Pypi release still got the old templates files, and all list filters still get dropped anyway.
Here's my current workaround:
change_form_template = "django_object_actions/change_form_filters.html"
change_list_template = "django_object_actions/change_list_filters.html"
def redirect_preserve_filters(self, request, obj, change_list=False):
opts = self.model._meta
preserved_filters = self.get_preserved_filters(request)
if change_list:
redir_url = reverse('admin:%s_%s_changelist' %
(opts.app_label, opts.model_name),
current_app=self.admin_site.name)
else:
pk_value = obj._get_pk_val()
redir_url = reverse('admin:%s_%s_change' %
(opts.app_label, opts.model_name),
args=(pk_value,),
current_app=self.admin_site.name)
preserved_filters = self.get_preserved_filters(request)
redir_url = add_preserved_filters({'preserved_filters': preserved_filters, 'opts': opts}, redir_url)
return HttpResponseRedirect(redir_url)
...
obj.save()
return self.redirect_preserve_filters(request, obj)
Please tell me if I got that wrong, and thanks again!
Is there a way to redirect an user after he clicked on an action and preserve applied filters?
Any help would be appreciated :)