Cannot upload multiple files using FileVar in Script #7532

Closed
opened 2025-12-29 20:24:49 +01:00 by adam · 4 comments
Owner

Originally created by @dainok on GitHub (Jan 19, 2023).

NetBox version

v3.4.2-dev

Python version

3.10

Steps to Reproduce

Create a Script using:

files = FileVar(
    description="Data file(s)",
    required=True,
    widget=forms.ClearableFileInput(attrs={"multiple": True}),
)

Upload multiple files and start the script.

Expected Behavior

I expect a list of files.

Warning: this could break compatibility, so files could be a list only if multiple files are uploaded.

I see netbox.extras.scripts.py as_form function (line 340) contains files which contains 2 files, but only one is keptduring the conversion. I tried to debug where the issue is, but I failed.

Observed Behavior

In the script execution, files contains only 1 file.

Originally created by @dainok on GitHub (Jan 19, 2023). ### NetBox version v3.4.2-dev ### Python version 3.10 ### Steps to Reproduce Create a Script using: ~~~ files = FileVar( description="Data file(s)", required=True, widget=forms.ClearableFileInput(attrs={"multiple": True}), ) ~~~ Upload multiple files and start the script. ### Expected Behavior I expect a list of files. Warning: this could break compatibility, so files could be a list only if multiple files are uploaded. I see netbox.extras.scripts.py as_form function (line 340) contains `files` which contains 2 files, but only one is keptduring the conversion. I tried to debug where the issue is, but I failed. ### Observed Behavior In the script execution, `files` contains only 1 file.
adam closed this issue 2025-12-29 20:24:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 19, 2023):

This is expected behavior; the form field supports only one file.

@jeremystretch commented on GitHub (Jan 19, 2023): This is expected behavior; the form field supports only one file.
Author
Owner

@dainok commented on GitHub (Jan 19, 2023):

Hello @jeremystretch thank you for your attention.

This has changed (I think recently) and now Django FileFieldForm support multiple files:

https://docs.djangoproject.com/en/4.1/topics/http/file-uploads/#uploading-multiple-files

I'm using that approach in another app.

@dainok commented on GitHub (Jan 19, 2023): Hello @jeremystretch thank you for your attention. This has changed (I think recently) and now Django FileFieldForm support multiple files: https://docs.djangoproject.com/en/4.1/topics/http/file-uploads/#uploading-multiple-files I'm using that approach in another app.
Author
Owner

@jeremystretch commented on GitHub (Jan 19, 2023):

I understand, however that functionality is not currently supported. (The view logic would also need to be extended.) You're welcome to submit a feature request outlining your use case for this functionality.

@jeremystretch commented on GitHub (Jan 19, 2023): I understand, however that functionality is not currently supported. (The view logic would also need to be extended.) You're welcome to submit a [feature request](https://github.com/netbox-community/netbox/issues/new?assignees=&labels=type%3A+feature&template=feature_request.yaml) outlining your use case for this functionality.
Author
Owner

@dainok commented on GitHub (Jan 19, 2023):

Thank you. Could you point me in the right direction to develop a patch?

@dainok commented on GitHub (Jan 19, 2023): Thank you. Could you point me in the right direction to develop a patch?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7532