axnsan12 / drf-yasg

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
https://drf-yasg.readthedocs.io/en/stable/
Other
3.42k stars 439 forks source link

cannot import name 'available_attrs' from 'django.utils.decorators' #650

Closed oneandonlyonebutyou closed 4 years ago

oneandonlyonebutyou commented 4 years ago

File ".pyenv/versions/3.7.3/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/urls.py", line 7, in from drf_yasg.views import get_schema_view File "/.venv/lib/python3.7/site-packages/drf_yasg/views.py", line 5, in from django.utils.decorators import available_attrs ImportError: cannot import name 'available_attrs' from 'django.utils.decorators' (/.venv/lib/python3.7/site-packages/django/utils/decorators.py)

oneandonlyonebutyou commented 4 years ago

@blueyed @blueyed @nedbat @beaugunderson Do you know?

beaugunderson commented 4 years ago

@joseph-vedadi looks like available_attrs was deprecated; you can replace that reference with one to functools.WRAPPER_ASSIGNMENTS (or downgrade django to a version before it was removed)

oneandonlyonebutyou commented 4 years ago

@beaugunderson Which version is that ?

beaugunderson commented 4 years ago

you can figure that out by searching the release notes :)

On Mon, Oct 5 2020 at 17:37, Joseph notifications@github.com wrote:

@beaugunderson https://github.com/beaugunderson Which version is that ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/axnsan12/drf-yasg/issues/650#issuecomment-703962205, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAPCX653TPIC3CIODPNTHTSJJRDBANCNFSM4SFHN7QA .

oneandonlyonebutyou commented 4 years ago

@beaugunderson Thank you :) When this package will be updated? So how am I supposed to update Django, if I lock it to "2.2.16" and now I get this error


ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'.
beaugunderson commented 4 years ago

i'm not sure about that error--i can tell you the versions we are using right now that work:

drf-yasg==1.17.1
django==3.0.7
django-rest-framework==3.11.0

as for when this will get updated, i can tell you that when my company needs to upgrade to django 3.1+ we'll likely open a PR here to fix the deprecations, but hopefully someone beats us to that :)

beaugunderson commented 4 years ago

@joseph-vedadi apologies, this fix is already in this library! so the initial version of drf-ysag you tried was too old; you should upgrade drf-yasg instead of downgrading django :)

you can see that WRAPPER_ASSIGNMENTS is imported here: https://github.com/axnsan12/drf-yasg/blob/master/src/drf_yasg/views.py#L2

oneandonlyonebutyou commented 4 years ago

so what combination you recommend ? Thank you so much for your help

beaugunderson commented 4 years ago

try the latest version of each :)

On Tue, Oct 06, 2020 at 10:50 AM, Joseph notifications@github.com wrote:

so what combination you recommend ? Thank you so much for your help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/axnsan12/drf-yasg/issues/650#issuecomment-704443048, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAPCX6WZPA5ZWQW25ZFVBLSJNKGHANCNFSM4SFHN7QA .

axnsan12 commented 4 years ago

Latest version now works for all django>=2.2 drf>=3.10. Closing.

eddiequinteros commented 2 years ago

It seems that this issue was either never fixed or it resurfaced again. Ubuntu 20.04.4 system up to date with latest packages and

pip list|grep drf

drf-yasg 1.20.0

pip list|grep Django

Django 3.2

pip list|grep django

django-appconf 1.0.3
django-compressor 2.2
django-debreach 2.0.1
django-pyscss 2.0.2
django-utils-six 2.0
djangorestframework 3.13.1

running openstack-horizon fails with ImportError: cannot import name 'available_attrs' from 'django.utils.decorators' (/usr/local/lib/python3.8/dist-packages/django/utils/decorators.py)

Several tracebacks at onc.

Apache log Traceback.txt