-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve List Filters #83
Comments
I don't think that's something that can be handled with |
crccheck
pushed a commit
that referenced
this issue
Apr 12, 2018
If you want to filter change_list by some conditions, then open each object and run some object action there, you will be returned to change_list with the same preserved filters. Fix #83 * Return to preserved filters on change_list after object action * Changes after pull request: Load add_preserved_filters from admin_urls * Changes after pull request: Indentation presumably reverted to original style
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:
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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to redirect an user after he clicked on an action and preserve applied filters?
Any help would be appreciated :)
The text was updated successfully, but these errors were encountered: