sphinx-doc / sphinxcontrib-django

This is a sphinx extension which improves the documentation of Django apps.
https://pypi.org/project/sphinxcontrib-django/
Apache License 2.0
43 stars 25 forks source link

ImportError: cannot import name 'available_attrs' from 'django.utils.decorators' #23

Closed eos-13 closed 1 year ago

eos-13 commented 4 years ago

Hi

using django 3 I got this error launching migrate command:

File "/home//.virtualenvs//lib/python3.7/site-packages/django/urls/conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home//.virtualenvs//lib/python3.7/site-packages/sphinxdoc/urls.py", line 7, in <module> from . import views File "/home//.virtualenvs//lib/python3.7/site-packages/sphinxdoc/views.py", line 20, in <module> from sphinxdoc.decorators import user_allowed_for_project File "/home//.virtualenvs//lib/python3.7/site-packages/sphinxdoc/decorators.py", line 7, in <module> from django.utils.decorators import available_attrs ImportError: cannot import name 'available_attrs' from 'django.utils.decorators' (/home//.virtualenvs//lib/python3.7/site-packages/django/utils/decorators.py)

Seems an issue with Django 3 as available_attrs seems not existing anymore. Can you have a look at it ?

eos-13 commented 4 years ago

in decorators.py:

change at line 1, 7 (removed) and 18 (don't know how to make a PR)

from functools import wraps, WRAPPER_ASSIGNMENTS

from django.contrib.auth.views import redirect_to_login
from django.core.exceptions import ImproperlyConfigured
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404

from sphinxdoc.models import Project

def user_allowed_for_project(view_func):
    """
    Check that the user is allowed for the project.

    If the user is not allowed, the view will be redirected to the standard
    login page.
    """
    @wraps(view_func, assigned=WRAPPER_ASSIGNMENTS)
    def _wrapped_view(request, *args, **kwargs):
        functools.WRAPPER_ASSIGNEMENTS
        try
timobrembeck commented 1 year ago

Hi @eos-13, thanks for reporting this issue, however I don't really understand how this error is related to this package. Or did you mean it as feature request, in case other people have this error as well? Since no one else did respond to this issue, I'd suggest to close it... Feel free to add more context information, so I can reconsider this topic.