From 7b6bd75c22196a28b6aa241b4146c6000ff3805c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 3 Mar 2020 09:43:56 -0500 Subject: [PATCH] #4295 follow-up: Tweak handling of initial data for bulk edit forms --- netbox/utilities/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/netbox/utilities/views.py b/netbox/utilities/views.py index 55e733178..e354c4dff 100644 --- a/netbox/utilities/views.py +++ b/netbox/utilities/views.py @@ -716,9 +716,15 @@ class BulkEditView(GetReturnURLMixin, View): messages.error(self.request, "{} failed validation: {}".format(obj, e)) else: - # Pass GET parameters as initial data for the form, and include the PK list - initial_data = request.GET.copy() - initial_data.update({'pk': pk_list}) + # Include the PK list as initial data for the form + initial_data = {'pk': pk_list} + + # Check for other contextual data needed for the form. We avoid passing all of request.GET because the + # filter values will conflict with the bulk edit form fields. + # TODO: Find a better way to accomplish this + if 'device' in request.GET: + initial_data['device'] = request.GET.get('device') + form = self.form(model, initial=initial_data) # Retrieve objects being edited