-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: initialize dropzoneSelector inside inline formsets in a Django 4.1 compatible way #1431
Conversation
….1 compatible way
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1431 +/- ##
=======================================
Coverage 76.43% 76.43%
=======================================
Files 75 75
Lines 3514 3514
Branches 562 562
=======================================
Hits 2686 2686
Misses 666 666
Partials 162 162 ☔ View full report in Codecov by Sentry. |
@mbi Is there any way to test this? How did you test? |
@fsbraun I tested manually, i.e. with an Django admin inline containing a FilerImageField. Without the patch, when you add a new row and drag a file onto the field, it doesn't react. With the PR applied, the field will react correctly and upload the file when dropped. |
Did you check it runs on Django 3.2? Probably we can drop the support for Django < 1.9, too. I think the if statement in line 165 and the else block in lines 190+ can go away: django-filer/filer/static/filer/js/addons/dropzone.init.js Lines 163 to 165 in 797fd21
django-filer/filer/static/filer/js/addons/dropzone.init.js Lines 190 to 195 in 797fd21
|
@fsbraun I just tested this on a 3.2 project, it works fine (as it was before: the new code line only triggers on 4.1+) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds straightforward enough and it's good to see the explanation of what's happening.
@fsbraun I'm always in favour of dropping support for unsupported Django. If we maintain support we're effectively encouraging people to use unsupported versions.
Thanks, @mbi ! Great work! |
Description
Django 4.1 changed the JavaScript event type being fired when adding a new formset from a jQuery to a vanilla JavaScript event. https://docs.djangoproject.com/en/4.1/ref/contrib/admin/javascript/
This broke the drag-and-drop feature when adding dynamic inlines containing Filer fields in e.g. the Django admin, because the dropzone failed to initialize.
This patch checks for Django 4.1 and initializes the dropzone on newly added inline rows.
Related resources
This fixes #1400.
Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.