소스 검색

Fixes #8947: Retain filter parameters when handling an export template exception

jeremystretch 3 년 전
부모
커밋
c78e7c14d3
2개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      docs/release-notes/version-3.1.md
  2. 4 1
      netbox/netbox/views/generic.py

+ 1 - 0
docs/release-notes/version-3.1.md

@@ -18,6 +18,7 @@
 * [#8924](https://github.com/netbox-community/netbox/issues/8924) - Improve load time of custom script list
 * [#8932](https://github.com/netbox-community/netbox/issues/8932) - Fix error when setting null value for interface `rf_role` via REST API
 * [#8935](https://github.com/netbox-community/netbox/issues/8935) - Correct ordering of next/previous racks to use naturalized names
+* [#8947](https://github.com/netbox-community/netbox/issues/8947) - Retain filter parameters when handling an export template exception
 * [#8951](https://github.com/netbox-community/netbox/issues/8951) - Allow changing device type & platform to different manufacturer simultaneously
 
 ---

+ 4 - 1
netbox/netbox/views/generic.py

@@ -212,7 +212,10 @@ class ObjectListView(ObjectPermissionRequiredMixin, View):
             return template.render_to_response(self.queryset)
         except Exception as e:
             messages.error(request, f"There was an error rendering the selected export template ({template.name}): {e}")
-            return redirect(request.path)
+            # Strip the `export` param and redirect user to the filtered objects list
+            query_params = request.GET.copy()
+            query_params.pop('export')
+            return redirect(f'{request.path}?{query_params.urlencode()}')
 
     def get(self, request):
         model = self.queryset.model