Skip to content

Conversation

@alxndrsn
Copy link

@alxndrsn alxndrsn commented Aug 3, 2023

Untested.

This change should filter files shown in the native file picker so that only .xls and .xlsx files are visible. This might be a usability improvement.


class UploadFileForm(forms.Form):
file = forms.FileField()
file = forms.FileField(attrs={ 'accept': '.xls, .xlsx' })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made this change to Central, and I've been a fan! However, when I checked this out locally, I saw an error:

  File "xlsform-online/xlsform_app/views.py", line 21, in UploadFileForm
    file = forms.FileField(attrs={ 'accept': '.xls, .xlsx' })
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/django/forms/fields.py", line 562, in __init__
    super().__init__(**kwargs)
TypeError: Field.__init__() got an unexpected keyword argument 'attrs'

I did a quick search, but I don't see an extremely simple option along these lines. Possibly you pass a FileInput as a widget to the FileField and specify accept on the FileInput?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for testing! It would be great to be able to run this project locally. 👋 #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants