diff --git a/CHANGELOG.md b/CHANGELOG.md index 31cc18af1..fdca3196b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ v2.6.1 (FUTURE) * [#3275](https://github.com/digitalocean/netbox/issues/3275) - Fix error when adding power outlets to a device type * [#3279](https://github.com/digitalocean/netbox/issues/3279) - Reset the PostgreSQL sequence for Tag and TaggedItem IDs * [#3290](https://github.com/digitalocean/netbox/issues/3290) - Fix server error when viewing cascaded PDUs +* [#3292](https://github.com/digitalocean/netbox/issues/3292) - Ignore empty URL query parameters --- diff --git a/netbox/utilities/filters.py b/netbox/utilities/filters.py index 614c09902..8ccdf2583 100644 --- a/netbox/utilities/filters.py +++ b/netbox/utilities/filters.py @@ -9,7 +9,7 @@ from extras.models import Tag def multivalue_field_factory(field_class): """ Given a form field class, return a subclass capable of accepting multiple values. This allows us to OR on multiple - filter values while maintaining the field's built-in vlaidation. Example: GET /api/dcim/devices/?name=foo&name=bar + filter values while maintaining the field's built-in validation. Example: GET /api/dcim/devices/?name=foo&name=bar """ class NewField(field_class): widget = forms.SelectMultiple @@ -17,7 +17,10 @@ def multivalue_field_factory(field_class): def to_python(self, value): if not value: return [] - return [super(field_class, self).to_python(v) for v in value] + return [ + # Only append non-empty values (this avoids e.g. trying to cast '' as an integer) + super(field_class, self).to_python(v) for v in value if v + ] return type('MultiValue{}'.format(field_class.__name__), (NewField,), dict())