django-import-export / django-import-export

Django application and library for importing and exporting data with admin integration.

Home Page:https://django-import-export.readthedocs.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`resource_class` was deprecated and removed, but it still works

matthewhegarty opened this issue · comments

Describe the bug

resource_class was removed in v4 in favour of resource_classes. However the following declaration still works:

class BookAdmin(ImportExportModelAdmin):
    list_display = ("name", "author", "added")
    list_filter = ["categories", "author"]
    resource_class = BookResource
    change_list_template = "core/admin/change_list.html"

We probably need to re-add the deprecation and ensure it is removed in a future release.

To Reproduce

update core/admin.py with the above snippet and you will find you can import a file ok.

commented

FYI: I think this caused a pretty nasty bug for me, because I think mistakenly using the deprecated resource_class prevents the class Meta: options from loading without giving a clear error message

I have re-added the deprecation warnings. I'll leave the issue open as a reminder to remove the deprecations and ensure that resource_class cannot be set in a future release.