diff --git a/CHANGES/plugin_api/9307.bugfix b/CHANGES/plugin_api/9307.bugfix new file mode 100644 index 0000000000..c6e90c4544 --- /dev/null +++ b/CHANGES/plugin_api/9307.bugfix @@ -0,0 +1,2 @@ +Set the default widget type to ``JSONWidget`` for ``JSONFields`` for Model Resources to fix +django-import-export bug where ``django.db.models.JSONFields`` weren't properly handled. diff --git a/pulpcore/plugin/importexport.py b/pulpcore/plugin/importexport.py index 88a4a7b73a..37b2402af4 100644 --- a/pulpcore/plugin/importexport.py +++ b/pulpcore/plugin/importexport.py @@ -1,4 +1,5 @@ from import_export import resources +from import_export.resources import widgets class QueryModelResource(resources.ModelResource): @@ -19,6 +20,11 @@ class QueryModelResource(resources.ModelResource): (driven by repo_version) """ + # TODO: remove this when https://git.io/JEgMp is released + # This forces JSONField to map to JSONWidget as django-import-export does not properly handle + # JSONField from django.db.models in django-import-export 2.5.0 + WIDGETS_MAP = {**resources.ModelResource.WIDGETS_MAP, **{"JSONField": widgets.JSONWidget}} + def set_up_queryset(self): return None