diff --git a/src/unfold/contrib/import_export/forms.py b/src/unfold/contrib/import_export/forms.py index b6ac9101..635cab51 100644 --- a/src/unfold/contrib/import_export/forms.py +++ b/src/unfold/contrib/import_export/forms.py @@ -15,23 +15,37 @@ class ImportForm(BaseImportForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["resource"].widget.attrs["class"] = " ".join(SELECT_CLASSES) - self.fields["import_file"].widget = UnfoldAdminFileFieldWidget() - self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES) + self.fields["resource"].widget.attrs["class"] = " ".join( + [self.fields["resource"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) + self.fields["import_file"].widget = UnfoldAdminFileFieldWidget( + attrs=self.fields["import_file"].widget.attrs + ) + self.fields["format"].widget.attrs["class"] = " ".join( + [self.fields["format"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) class ExportForm(BaseExportForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["resource"].widget.attrs["class"] = " ".join(SELECT_CLASSES) - self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES) + self.fields["resource"].widget.attrs["class"] = " ".join( + [self.fields["resource"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) + self.fields["format"].widget.attrs["class"] = " ".join( + [self.fields["format"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) class SelectableFieldsExportForm(BaseSelectableFieldsExportForm): def __init__(self, formats, resources, **kwargs): super().__init__(formats, resources, **kwargs) - self.fields["resource"].widget.attrs["class"] = " ".join(SELECT_CLASSES) - self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES) + self.fields["resource"].widget.attrs["class"] = " ".join( + [self.fields["resource"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) + self.fields["format"].widget.attrs["class"] = " ".join( + [self.fields["format"].widget.attrs.get("class", ""), *SELECT_CLASSES] + ) for _key, field in self.fields.items(): if isinstance(field, BooleanField): diff --git a/src/unfold/contrib/import_export/templates/admin/import_export/export.html b/src/unfold/contrib/import_export/templates/admin/import_export/export.html index 1aafd62c..b91a17c8 100644 --- a/src/unfold/contrib/import_export/templates/admin/import_export/export.html +++ b/src/unfold/contrib/import_export/templates/admin/import_export/export.html @@ -54,7 +54,7 @@