#31527: Admindocs' View index assumes settings.ROOT_URLCONF is an import string
---------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admindocs | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
Currently, the code looks like:
{{{
urlconf = import_module(settings.ROOT_URLCONF)
view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns)
}}}
Buuuuuuuut, it's possible to get Django to otherwise run with, for
example, something like:
{{{
def urlpatterns():
from django.urls import path
from django.contrib import admin
return (
path("admin/", admin.site.urls),
)
ROOT_URLCONF = SimpleLazyObject(urlpatterns)
}}}
which will happily pass through the checks framework, and runserver (and
gunicorn), and let you use Django as you otherwise would... except for
navigating to `django.contrib.admindocs.views.ViewIndexView` (for example,
routed at `/admin/doc/views/`) where you'll instead encounter an exception
like:
{{{
File "/path/to/python3.7/site-packages/django/contrib/admindocs/views.py"
in dispatch
46. return super().dispatch(request, *args, **kwargs)
File "/path/to/python3.7/site-packages/django/views/generic/base.py" in
dispatch
97. return handler(request, *args, **kwargs)
File "/path/to/python3.7/site-packages/django/views/generic/base.py" in
get
158. context = self.get_context_data(**kwargs)
File "/path/to/python3.7/site-packages/django/contrib/admindocs/views.py"
in get_context_data
139. urlconf = import_module(settings.ROOT_URLCONF)
File "/path/to/python3.7/importlib/__init__.py" in import_module
118. if name.startswith('.'):
File "/path/to/python3.7/site-packages/django/utils/functional.py" in
inner
257. return func(self._wrapped, *args)
Exception Type: AttributeError at /admin/doc/views/
Exception Value: 'tuple' object has no attribute 'startswith'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31527>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.4d4eb678d194ac48b497375bc50d6575%40djangoproject.com.