diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 8e0aacc..26bda21 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
884 | 884 | post_url = reverse('admin:%s_%s_changelist' % |
885 | 885 | (opts.app_label, opts.module_name), |
886 | 886 | current_app=self.admin_site.name) |
| 887 | post_url += self.changelist_redirect_querystring(request) |
887 | 888 | else: |
888 | 889 | post_url = reverse('admin:index', |
889 | 890 | current_app=self.admin_site.name) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
956 | 957 | self.message_user(request, msg) |
957 | 958 | return None |
958 | 959 | |
| 960 | def changelist_redirect_querystring(self, request): |
| 961 | opts = self.model._meta |
| 962 | return request.session.get( |
| 963 | 'admin_%s_%s_changelist_querystring' % (opts.app_label, opts.module_name), '') |
| 964 | |
959 | 965 | @csrf_protect_m |
960 | 966 | @transaction.commit_on_success |
961 | 967 | def add_view(self, request, form_url='', extra_context=None): |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1282 | 1288 | } |
1283 | 1289 | context.update(extra_context or {}) |
1284 | 1290 | |
| 1291 | if request.method == 'GET': |
| 1292 | # Store the querystring in the session so we can return to the |
| 1293 | # same filtered changelist later, for example after an object has |
| 1294 | # been saved or deleted. |
| 1295 | request.session['admin_%s_%s_changelist_querystring' % ( |
| 1296 | opts.app_label, opts.module_name)] = cl.get_query_string() |
| 1297 | |
1285 | 1298 | return TemplateResponse(request, self.change_list_template or [ |
1286 | 1299 | 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), |
1287 | 1300 | 'admin/%s/change_list.html' % app_label, |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
1322 | 1335 | if not self.has_change_permission(request, None): |
1323 | 1336 | return HttpResponseRedirect(reverse('admin:index', |
1324 | 1337 | current_app=self.admin_site.name)) |
1325 | | return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % |
| 1338 | url = reverse('admin:%s_%s_changelist' % |
1326 | 1339 | (opts.app_label, opts.module_name), |
1327 | | current_app=self.admin_site.name)) |
| 1340 | current_app=self.admin_site.name) |
| 1341 | url += self.changelist_redirect_querystring(request) |
| 1342 | return HttpResponseRedirect(url) |
1328 | 1343 | |
1329 | 1344 | object_name = force_text(opts.verbose_name) |
1330 | 1345 | |
diff --git a/tests/regressiontests/admin_changelist/tests.py b/tests/regressiontests/admin_changelist/tests.py
index 7a3a5c0..6c98194 100644
a
|
b
|
class ChangeListTests(TestCase):
|
35 | 35 | def _mocked_authenticated_request(self, url, user): |
36 | 36 | request = self.factory.get(url) |
37 | 37 | request.user = user |
| 38 | request.session = {} |
38 | 39 | return request |
39 | 40 | |
40 | 41 | def test_select_related_preserved(self): |