-
Notifications
You must be signed in to change notification settings - Fork 180
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
How to use SortableAdminMixin together with ImportExportModelAdmin from django-import-export? #345
Comments
Please read the contribution guidelines. |
I'm sorry. I am not sure where to look. Do you have own contribution guidelines for questions? Can you please point me to them? |
Please read here: Fork the repository, and adopt that demo to use |
I recreated the bug in a fork: https://github.com/micudaj/django-admin-sortable2/tree/import-export-bug |
Okay, thanks! |
To get adminsortable2 and import-export working together I have the following: admin.py
Then to have both the adminsortable2 drag handles and the import-export buttons on the admin change list create the following template in your project template directory such that it will override the template included in the adminsortable2 package. my_project/templates/adminsortable2/change_list.html
Thing is it looks like adminsortable2 will extend it's change list template from whatever you set the changelist_template attribute on your model admin to be. So you might think you can set it to one of the change list templates in import-export and adminsortable2 will extend that and the buttons will appear - but... import-export also implements this feature in a very similar way and uses exactly the same variable name when extending the changelist_template So I felt it was acceptable to solve this via the template override above. I could have just as easily extended the import-export template and copied the content from adminsortable2 but since import-export provides templates to include for their buttons I feel this way is better. I'm not sure this needs fixing. Perhaps it could be fixed by renaming the |
I was able to make work sorting with import/export butons just by explicitly setting class MyAdmin(ImportExportMixin, SortableAdminMixin, admin.ModelAdmin):
change_list_template = "admin/import_export/change_list.html" This seems to be issue of If the order of mixins is reversed (
|
Yes, this is because the change was applied in django-admin-sortable2 and then ported to django-import-export. The purpose was to try to make it easier for the two packages to work together. |
Hi Petr, when I use you suggestion I can see drag handles and import / export on the page, but the drag handles are not working. I see that they do not get any event handler assigned for drag events. Do you have any idea what I could do? |
There are 3 remaining issues in this library which causes this issue:
|
Hi, did someone figure out a workaround so far or is there any update on this issue? :) |
Solution {% block object-tools-items %} |
I tried to use ImportExportModelAdmin together with SortableAdminMixin from admin-sortable2, but I get the following error. Any idea how and if these can work together?
Error during template rendering
In template /Users/mim/Downloads/sourcecode/django/django-klimawahlen/venv/lib/python3.10/site-packages/adminsortable2/templates/adminsortable2/change_list.html, error at line 1
join() argument must be str, bytes, or os.PathLike object, not 'list'
The text was updated successfully, but these errors were encountered: