Skip to content

Commit

Permalink
Closes #5995: Dropped backward compatibility for queryset parameter o…
Browse files Browse the repository at this point in the history
…n ObjectVar and MultiObjectVar
  • Loading branch information
jeremystretch committed Mar 16, 2021
1 parent a694dbb commit 46a0244
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/version-2.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [#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
* [#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

Expand Down
14 changes: 2 additions & 12 deletions netbox/extras/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ObjectVar(ScriptVariable):
"""
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
if 'display_field' in kwargs:
Expand All @@ -198,18 +198,8 @@ def __init__(self, model=None, queryset=None, query_params=None, null_option=Non

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({
'queryset': model.objects.all(),
'display_field': display_field,
'query_params': query_params,
'null_option': null_option,
Expand Down

0 comments on commit 46a0244

Please sign in to comment.