Skip to content

Commit 299bde9

Browse files
matejvjeremystretch
authored andcommitted
use script form's cleaned data when calling script from CLI
so ObjectVar and other field values have proper types in script's data variable
1 parent 4b98f74 commit 299bde9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

netbox/extras/management/commands/runscript.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@ def handle(self, *args, **options):
8181
logger.error(f'\t{field}: {error.get("message")}')
8282
raise CommandError()
8383

84+
# Remove extra fields from ScriptForm before passng data to script
85+
form.cleaned_data.pop('_schedule_at')
86+
form.cleaned_data.pop('_interval')
87+
form.cleaned_data.pop('_commit')
88+
8489
# Execute the script.
8590
job = ScriptJob.enqueue(
8691
instance=script_obj,
8792
user=user,
8893
immediate=True,
89-
data=data,
94+
data=form.cleaned_data,
9095
request=NetBoxFakeRequest({
9196
'META': {},
9297
'POST': data,

0 commit comments

Comments
 (0)