Skip to content

Conversation

@ZairMahmood
Copy link

Issue

Import action is broken per changes from #398

Resource was inferred as the file field but it's a different field on its own. Current issue can also be observed on the deployed unfoldadmin/formula
The actual file is never passed back to import-export since the expected input_file field is missing.

Changes

Reverting partial changes from #398 while cleaning up the formatting a touch to manage multiple resources

Single Resource View:
Screenshot 2024-05-21 at 3 44 50 PM

Multiple Resource View:
Screenshot 2024-05-21 at 3 45 05 PM

Tests

Tested locally with:
[email protected]
django@5
[email protected]

I didn't go too deep in the export action and how resources might play a part there since it was functional and not completely broken.

{% csrf_token %}

<p class="bg-blue-50 mb-8 text-blue-500 px-3 py-3 rounded-md text-sm dark:bg-blue-500/20 dark:border-blue-500/10">
<div class="bg-blue-50 mb-8 text-blue-500 px-3 py-3 rounded-md text-sm dark:bg-blue-500/20 dark:border-blue-500/10">
Copy link
Author

Choose a reason for hiding this comment

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

Since dl tags can't be inside p tag, switched to div to capture implemented classes

self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES)
resource_widget = self.fields["resource"].widget
if len(resource_widget.choices) > 0:
self.fields["resource"].widget = UnfoldAdminSelectWidget(
Copy link
Author

Choose a reason for hiding this comment

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

Replaced to using widgets here since they're already part of the unfold project and don't have to rewrite the same logic.
Not sure if there was a proper way of using this widget but this worked instead of just UnfoldAdminSelectWidget

@ZairMahmood
Copy link
Author

Another suggestion for future is that the UnfoldAdminFileFieldWidget can allow upload from clicking anywhere inside of the box instead just the little icon off to the side.

@ZairMahmood
Copy link
Author

I didn't go thru each template from import_export but possibly needs some updates/restyling there also to match updates from their v4

@lukasvinclav
Copy link
Contributor

First of all, thank you very much for high quality feedback. Based on your code, I created new PR fixing multiple issues. If you have time, would you mind to test my PR and provide another feedback?

https://github.com/unfoldadmin/django-unfold/pull/404/files

@lukasvinclav
Copy link
Contributor

Closing in favor of #404. Thank you very much for valuable feedback.

@ZairMahmood ZairMahmood deleted the fix/django-import-export-4 branch June 25, 2024 07:36
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