mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixes #3292: Ignore empty URL query parameters
This commit is contained in:
parent
70ef6a69ee
commit
653770ede9
@ -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
|
* [#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
|
* [#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
|
* [#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
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from extras.models import Tag
|
|||||||
def multivalue_field_factory(field_class):
|
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
|
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):
|
class NewField(field_class):
|
||||||
widget = forms.SelectMultiple
|
widget = forms.SelectMultiple
|
||||||
@ -17,7 +17,10 @@ def multivalue_field_factory(field_class):
|
|||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
if not value:
|
if not value:
|
||||||
return []
|
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())
|
return type('MultiValue{}'.format(field_class.__name__), (NewField,), dict())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user