abogushov / django-admin-json-editor

Adds json-editor for JSONField in Django Administration
MIT License
173 stars 61 forks source link

Issue with python 3.10 #42

Open mattiagiupponi opened 1 year ago

mattiagiupponi commented 1 year ago

Hi, I'm using python 3.10 and the library raised this issue due to an incompatibility:

  File "/usr/local/lib/python3.10/dist-packages/django/forms/boundfield.py", line 34, in __str__
    return self.as_widget()
  File "/usr/local/lib/python3.10/dist-packages/django/forms/boundfield.py", line 93, in as_widget
    return widget.render(
  File "/usr/local/lib/python3.10/dist-packages/django_admin_json_editor/admin.py", line 24, in render
    self.schema_updater(schema)
  File "/usr/local/lib/python3.10/dist-packages/django_admin_json_editor/admin.py", line 41, in schema_updater
    if isinstance(value, collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'

This way of importing the module has been deprecated since python 3.3:

DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' has been deprecated since Python 3.3, and in 3.10 it will stop working

It should be enough to change the import statement from import collection to from collections.abc import Mapping

mikespallino commented 3 weeks ago

I know you're probably moved on from this problem, but this is not an issue with versions of this package >=0.2.0. The method containing the code in the traceback was removed in that release https://github.com/abogushov/django-admin-json-editor/compare/0.1.5...0.2.0#diff-79b0fa4a0d3f5c2770a9c3d127215aab4937042f912d8f92c7573f784303aff6L37-L46