mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Closes #5995: Dropped backward compatibility for queryset parameter on ObjectVar and MultiObjectVar
This commit is contained in:
parent
a694dbb020
commit
46a024441c
@ -85,6 +85,7 @@ The ObjectChange model (which is used to record the creation, modification, and
|
|||||||
* [#1638](https://github.com/netbox-community/netbox/issues/1638) - Migrate all primary keys to 64-bit integers
|
* [#1638](https://github.com/netbox-community/netbox/issues/1638) - Migrate all primary keys to 64-bit integers
|
||||||
* [#5873](https://github.com/netbox-community/netbox/issues/5873) - Use numeric IDs in all object URLs
|
* [#5873](https://github.com/netbox-community/netbox/issues/5873) - Use numeric IDs in all object URLs
|
||||||
* [#5990](https://github.com/netbox-community/netbox/issues/5990) - Deprecated `display_field` parameter for custom script ObjectVar and MultiObjectVar fields
|
* [#5990](https://github.com/netbox-community/netbox/issues/5990) - Deprecated `display_field` parameter for custom script ObjectVar and MultiObjectVar fields
|
||||||
|
* [#5995](https://github.com/netbox-community/netbox/issues/5995) - Dropped backward compatibility for `queryset` parameter on ObjectVar and MultiObjectVar (use `model` instead)
|
||||||
|
|
||||||
### REST API Changes
|
### REST API Changes
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class ObjectVar(ScriptVariable):
|
|||||||
"""
|
"""
|
||||||
form_field = DynamicModelChoiceField
|
form_field = DynamicModelChoiceField
|
||||||
|
|
||||||
def __init__(self, model=None, queryset=None, query_params=None, null_option=None, *args, **kwargs):
|
def __init__(self, model, query_params=None, null_option=None, *args, **kwargs):
|
||||||
|
|
||||||
# TODO: Remove display_field in v2.12
|
# TODO: Remove display_field in v2.12
|
||||||
if 'display_field' in kwargs:
|
if 'display_field' in kwargs:
|
||||||
@ -198,18 +198,8 @@ class ObjectVar(ScriptVariable):
|
|||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# Set the form field's queryset. Support backward compatibility for the "queryset" argument for now.
|
|
||||||
if model is not None:
|
|
||||||
self.field_attrs['queryset'] = model.objects.all()
|
|
||||||
elif queryset is not None:
|
|
||||||
warnings.warn(
|
|
||||||
f'{self}: Specifying a queryset for ObjectVar is no longer supported. Please use "model" instead.'
|
|
||||||
)
|
|
||||||
self.field_attrs['queryset'] = queryset
|
|
||||||
else:
|
|
||||||
raise TypeError('ObjectVar must specify a model')
|
|
||||||
|
|
||||||
self.field_attrs.update({
|
self.field_attrs.update({
|
||||||
|
'queryset': model.objects.all(),
|
||||||
'display_field': display_field,
|
'display_field': display_field,
|
||||||
'query_params': query_params,
|
'query_params': query_params,
|
||||||
'null_option': null_option,
|
'null_option': null_option,
|
||||||
|
Loading…
Reference in New Issue
Block a user