Skip to content
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

ImportExportMixin overlaps change_list_template property making it not compatible with other mixins #1450

Closed
PetrDlouhy opened this issue Jun 10, 2022 · 2 comments
Labels

Comments

@PetrDlouhy
Copy link
Contributor

Describe the bug
If I combine ImportExportMixin with SortableAdminMixin from django-admin-sortable2 I can't get both functionalities to work together.
I have already described the issue and made PR for django-admin-sortable2: jrief/django-admin-sortable2#316
That fixes the issue combined usage of mixins from these two applications, but the same issue is present in django-admin-sortable2 as well and could raise problems when combining with other applications (or if user sets up different change_list_template parameter).

The same principle to fix this should be used also for django-import-export. Setting of the change_list_template parameters in ImportMixin, ExportMixin, ImportExportMixin should be moved to __init__, the original value should be stored and used in {% extends %} tag of the admin/change_list.html template.

Versions (please complete the following information):

  • Django Import Export: 4.0.2
  • Python 3.10
  • Django 4.0
@PetrDlouhy PetrDlouhy added the bug label Jun 10, 2022
@pokken-magic
Copy link

Wanted to say thanks for this info, used it to resolve a similar problem. Likely something we ought to fix in the main code!

nikhaldi pushed a commit to nikhaldi/django-import-export that referenced this issue Aug 30, 2022
This allows users to customize the change list templates when using mixins
provided by the library. In particular this enables adding more items to
the object tools, in addition to the ones added by the admin mixins. This
then makes this library compatible with other libraries that extend the
objec tools, such as `django-admin-sortable2` or `reversion`.

Fixes django-import-export#1450
@nikhaldi
Copy link

I've submitted a PR I think addresses this problem. I ran into this in combination with the reversion library, not django-admin-sortable2, but the underlying issue is the same.

nikhaldi pushed a commit to nikhaldi/django-import-export that referenced this issue Aug 31, 2022
This allows users to customize the change list templates when using mixins
provided by the library. In particular this enables adding more items to
the object tools, in addition to the ones added by the admin mixins. This
then makes this library compatible with other libraries that extend the
object tools, such as `django-admin-sortable2` or `reversion`.

Fixes django-import-export#1450
matthewhegarty pushed a commit that referenced this issue Sep 6, 2022
* Allow custom change_list_template in admin views using mixins

This allows users to customize the change list templates when using mixins
provided by the library. In particular this enables adding more items to
the object tools, in addition to the ones added by the admin mixins. This
then makes this library compatible with other libraries that extend the
object tools, such as `django-admin-sortable2` or `reversion`.

Fixes #1450

* Turn custom test change list item into real link

Looks less confusing like this in the demo app.

* Don't make custom change list template test affect the rendering

Should avoid confusion by users using the sample application.

* Update changelog.rst

* Describe potential breaking changes

* Make sure test template customization doesn't render

* corrected typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants