Skip to content

Commit

Permalink
use script form's cleaned data when calling script from CLI
Browse files Browse the repository at this point in the history
so ObjectVar and other field values have proper types in script's data variable
  • Loading branch information
matejv authored and jeremystretch committed Feb 10, 2025
1 parent 4b98f74 commit 299bde9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion netbox/extras/management/commands/runscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,17 @@ def handle(self, *args, **options):
logger.error(f'\t{field}: {error.get("message")}')
raise CommandError()

# Remove extra fields from ScriptForm before passng data to script
form.cleaned_data.pop('_schedule_at')
form.cleaned_data.pop('_interval')
form.cleaned_data.pop('_commit')

# Execute the script.
job = ScriptJob.enqueue(
instance=script_obj,
user=user,
immediate=True,
data=data,
data=form.cleaned_data,
request=NetBoxFakeRequest({
'META': {},
'POST': data,
Expand Down

0 comments on commit 299bde9

Please sign in to comment.