Skip to content
Permalink
Browse files

Fixes #4175: Fix potential exception when bulk editing objects from a…

… filtered list
  • Loading branch information
jeremystretch committed Feb 14, 2020
1 parent 2de8d8b commit 1a8eea5aa943f4f63b76ecadcf9ee7c4ab60e6e2
Showing with 4 additions and 7 deletions.
  1. +1 −0 docs/release-notes/version-2.7.md
  2. +2 −2 netbox/templates/utilities/obj_list.html
  3. +1 −5 netbox/utilities/views.py
@@ -9,6 +9,7 @@

* [#2519](https://github.com/netbox-community/netbox/issues/2519) - Avoid race condition when provisioning "next available" IPs/prefixes via the API
* [#4168](https://github.com/netbox-community/netbox/issues/4168) - Role is not required when creating a virtual machine
* [#4175](https://github.com/netbox-community/netbox/issues/4175) - Fix potential exception when bulk editing objects from a filtered list

---

@@ -51,12 +51,12 @@ <h1>{% block title %}{{ content_type.model_class|model_name_plural|bettertitle }
<div class="pull-left noprint">
{% block bulk_buttons %}{% endblock %}
{% if bulk_edit_url and permissions.change %}
<button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
<button type="submit" name="_edit" formaction="{% url bulk_edit_url %}" class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit Selected
</button>
{% endif %}
{% if bulk_delete_url and permissions.delete %}
<button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
<button type="submit" name="_delete" formaction="{% url bulk_delete_url %}" class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete Selected
</button>
{% endif %}
@@ -634,7 +634,7 @@ def post(self, request, **kwargs):
post_data['pk'] = [obj.pk for obj in self.filterset(request.GET, model.objects.only('pk')).qs]

if '_apply' in request.POST:
form = self.form(model, request.POST, initial=request.GET)
form = self.form(model, request.POST)
if form.is_valid():

custom_fields = form.custom_fields if hasattr(form, 'custom_fields') else []
@@ -718,10 +718,6 @@ def post(self, request, **kwargs):
else:
# Pass the PK list as initial data to avoid binding the form
initial_data = querydict_to_dict(post_data)

# Append any normal initial data (passed as GET parameters)
initial_data.update(request.GET)

form = self.form(model, initial=initial_data)

# Retrieve objects being edited

0 comments on commit 1a8eea5

Please sign in to comment.
You can’t perform that action at this time.