Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #4255 - Modify script ObjectVars to utilize DynamicModelChoiceField #4258

Merged
merged 6 commits into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions netbox/extras/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ipam.validators import MaxPrefixLengthValidator, MinPrefixLengthValidator, prefix_validator
from .constants import LOG_DEFAULT, LOG_FAILURE, LOG_INFO, LOG_SUCCESS, LOG_WARNING
from utilities.exceptions import AbortTransaction
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField
from .forms import ScriptForm
from .signals import purge_changelog

Expand Down Expand Up @@ -167,7 +168,7 @@ class ObjectVar(ScriptVariable):
"""
NetBox object representation. The provided QuerySet will determine the choices available.
"""
form_field = forms.ModelChoiceField
form_field = DynamicModelChoiceField

def __init__(self, queryset, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -184,7 +185,7 @@ class MultiObjectVar(ScriptVariable):
"""
Like ObjectVar, but can represent one or more objects.
"""
form_field = forms.ModelMultipleChoiceField
form_field = DynamicModelMultipleChoiceField

def __init__(self, queryset, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down