Opened 2 years ago
Last modified 2 years ago
#33955 closed Bug
AttributeError in admindocs ViewDetailView — at Version 3
Reported by: | Greg Kaleka | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admindocs | Version: | 4.1 |
Severity: | Release blocker | Keywords: | |
Cc: | Carlton Gibson, Alokik Roy | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
In Django 4.1, the admindocs ViewDetailView
raises an AttributeError
. I'm not clear on why _active
is missing the local_value
attribute when _is_callback
is called.
Reproduction steps:
- Create a new project with Django 4.1
- Include
django.contrib.admindocs
in your installed apps - Add the urls to your urlconf:
path("admindocs/", include("django.contrib.admindocs.urls"))
- Go to
localhost:8000/admindocs/views/
and click on any view to go to theViewDetailView
Quick and dirty fix in django/contrib/admindocs/utils.py
:
Code highlighting:
def _is_callback(name, urlresolver=None): if not hasattr(_active, "local_value"): _active.local_value = _callback_strs if urlresolver and not urlresolver._populated: register_callback(urlresolver, _active.local_value) return name in _active.local_value
and here's the full traceback before the fix:
Internal Server Error: /admindocs/views/django.contrib.admindocs.views.BaseAdminDocsView/ Traceback (most recent call last): File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 103, in view return self.dispatch(request, *args, **kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 46, in _wrapper return bound_method(*args, **kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/contrib/admindocs/views.py", line 50, in dispatch return super().dispatch(request, *args, **kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch return handler(request, *args, **kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 216, in get context = self.get_context_data(**kwargs) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/contrib/admindocs/views.py", line 185, in get_context_data view_func = self._get_view_func(view) File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/contrib/admindocs/views.py", line 169, in _get_view_func if _is_callback(view): File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/django/contrib/admindocs/utils.py", line 258, in _is_callback return name in _active.local_value File "/Users/gkaleka/dev/testing/django_41_testfix/.venv/lib/python3.9/site-packages/asgiref/local.py", line 105, in __getattr__ raise AttributeError(f"{self!r} object has no attribute {key!r}") AttributeError: <asgiref.local.Local object at 0x10a4f7670> object has no attribute 'local_value'
Change History (3)
comment:1 by , 2 years ago
Description: | modified (diff) |
---|
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
comment:3 by , 2 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.