mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into develop-2.9
This commit is contained in:
@@ -152,6 +152,24 @@ def dict_to_filter_params(d, prefix=''):
|
||||
return params
|
||||
|
||||
|
||||
def normalize_querydict(querydict):
|
||||
"""
|
||||
Convert a QueryDict to a normal, mutable dictionary, preserving list values. For example,
|
||||
|
||||
QueryDict('foo=1&bar=2&bar=3&baz=')
|
||||
|
||||
becomes:
|
||||
|
||||
{'foo': '1', 'bar': ['2', '3'], 'baz': ''}
|
||||
|
||||
This function is necessary because QueryDict does not provide any built-in mechanism which preserves multiple
|
||||
values.
|
||||
"""
|
||||
return {
|
||||
k: v if len(v) > 1 else v[0] for k, v in querydict.lists()
|
||||
}
|
||||
|
||||
|
||||
def deepmerge(original, new):
|
||||
"""
|
||||
Deep merge two dictionaries (new into original) and return a new dict
|
||||
|
||||
Reference in New Issue
Block a user