Skip to content

Commit

Permalink
Remove widget instance deprecation warning (#1794)
Browse files Browse the repository at this point in the history
* removed passing 'instance' to widget render() and removed deprecation warnings

* updated release notes

* updated release notes link
  • Loading branch information
matthewhegarty committed Apr 25, 2024
1 parent f75adc0 commit 475b00f
Show file tree
Hide file tree
Showing 24 changed files with 4 additions and 224 deletions.
2 changes: 1 addition & 1 deletion docs/_static/images/export_workflow.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/release_notes.rst
Expand Up @@ -75,6 +75,7 @@ Deprecations
* The ``obj`` param passed to :meth:`~import_export.widgets.Widget.render` is deprecated.
The :meth:`~import_export.widgets.Widget.render` method should not need to have a reference to
model instance.
The call to :meth:`~import_export.widgets.Widget.render` from :meth:`~import_export.fields.Field.export` has been removed.

* Use of ``ExportViewFormMixin`` is deprecated. See `this issue <https://github.com/django-import-export/django-import-export/issues/1666>`_.

Expand Down
2 changes: 1 addition & 1 deletion import_export/fields.py
Expand Up @@ -146,7 +146,7 @@ def export(self, instance):
representation.
"""
value = self.get_value(instance)
return self.widget.render(value, instance)
return self.widget.render(value)

def get_dehydrate_method(self, field_name=None):
"""
Expand Down
5 changes: 0 additions & 5 deletions tests/core/tests/admin_integration/test_action.py
Expand Up @@ -5,7 +5,6 @@
from core.admin import CategoryAdmin
from core.models import Book, Category
from core.tests.admin_integration.mixins import AdminTestMixin
from core.tests.utils import ignore_widget_deprecation_warning
from django.contrib import admin
from django.core.exceptions import PermissionDenied
from django.http import HttpRequest
Expand Down Expand Up @@ -40,7 +39,6 @@ def _check_export_response(self, response):
)

@override_settings(IMPORT_EXPORT_SKIP_ADMIN_ACTION_EXPORT_UI=True)
@ignore_widget_deprecation_warning
def test_export_skips_export_ui_page(self):
data = {
"action": ["export_admin_action"],
Expand All @@ -49,7 +47,6 @@ def test_export_skips_export_ui_page(self):
response = self.client.post("/admin/core/category/", data)
self._check_export_response(response)

@ignore_widget_deprecation_warning
def test_export_displays_ui_select_page(self):
data = {
"action": ["export_admin_action"],
Expand All @@ -64,7 +61,6 @@ def test_export_displays_ui_select_page(self):
self.assertEqual([self.cat1.id], data["export_items"])
self.assertIn("Export 1 selected item.", str(response.content))

@ignore_widget_deprecation_warning
def test_export_displays_ui_select_page_multiple_items(self):
data = {
"action": ["export_admin_action"],
Expand All @@ -81,7 +77,6 @@ def test_export_displays_ui_select_page_multiple_items(self):
)
self.assertIn("Export 2 selected items.", str(response.content))

@ignore_widget_deprecation_warning
def test_export_post(self):
# create a POST request with data selected from the 'action' export
data = {
Expand Down
9 changes: 1 addition & 8 deletions tests/core/tests/admin_integration/test_export.py
Expand Up @@ -8,10 +8,7 @@
from core.admin import BookAdmin, BookResource
from core.models import Author, Book
from core.tests.admin_integration.mixins import AdminTestMixin
from core.tests.utils import (
ignore_utcnow_deprecation_warning,
ignore_widget_deprecation_warning,
)
from core.tests.utils import ignore_utcnow_deprecation_warning
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.models import User
Expand Down Expand Up @@ -253,7 +250,6 @@ def test_returns_xlsx_export(self):

@ignore_utcnow_deprecation_warning
@override_settings(IMPORT_EXPORT_ESCAPE_FORMULAE_ON_EXPORT=True)
@ignore_widget_deprecation_warning
def test_export_escape_formulae(self):
Book.objects.create(id=1, name="=SUM(1+1)")
Book.objects.create(id=2, name="<script>alert(1)</script>")
Expand All @@ -270,7 +266,6 @@ def test_export_escape_formulae(self):
self.assertEqual("SUM(1+1)", wb.active["B3"].value)

@override_settings(IMPORT_EXPORT_ESCAPE_FORMULAE_ON_EXPORT=True)
@ignore_widget_deprecation_warning
def test_export_escape_formulae_csv(self):
b1 = Book.objects.create(id=1, name="=SUM(1+1)")
response = self.client.get("/admin/core/book/export/")
Expand All @@ -289,7 +284,6 @@ def test_export_escape_formulae_csv(self):
)

@override_settings(IMPORT_EXPORT_ESCAPE_FORMULAE_ON_EXPORT=False)
@ignore_widget_deprecation_warning
def test_export_escape_formulae_csv_false(self):
b1 = Book.objects.create(id=1, name="=SUM(1+1)")
response = self.client.get("/admin/core/book/export/")
Expand All @@ -311,7 +305,6 @@ def test_export_escape_formulae_csv_false(self):
class FilteredExportAdminIntegrationTest(AdminTestMixin, TestCase):
fixtures = ["category", "book", "author"]

@ignore_widget_deprecation_warning
def test_export_filters_by_form_param(self):
# issue 1578
author = Author.objects.get(name="Ian Fleming")
Expand Down

0 comments on commit 475b00f

Please sign in to comment.