Closes #5995: Dropped backward compatibility for queryset parameter on ObjectVar and MultiObjectVar

This commit is contained in:
Jeremy Stretch 2021-03-16 11:28:50 -04:00
parent a694dbb020
commit 46a024441c
2 changed files with 3 additions and 12 deletions

View File

@ -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

View File

@ -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,