Opened 7 years ago
Last modified 7 years ago
#29296 closed Bug
admindocs crash if a Feed is configured — at Version 3
Reported by: | Paul Donohue | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admindocs | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If a Feed (https://docs.djangoproject.com/en/2.0/ref/contrib/syndication/) is configured anywhere in the project, then /admin/doc/views/ (https://docs.djangoproject.com/en/2.0/ref/contrib/admin/admindocs/) crashes with AttributeError: 'GlobalFeed' object has no attribute '__qualname__'
The problem is that Feed is a callable object (https://github.com/django/django/blob/master/django/contrib/syndication/views.py#L34) and the documentation uses that class directly as a View (path('latest/feed/', LatestEntriesFeed()),
), but admindocs assumes that all views are functions and it does not work properly with a callable object (https://github.com/django/django/blob/master/django/contrib/admindocs/views.py#L130).
In Django 1.11 and earlier, admindocs supported callable objects on Python 2 because it fell back to view.__class__.__name__
, but it appears that the Python 3 code in admindocs has not supported this since it was added in https://github.com/django/django/commit/ae0f55eb491255217d6df31296ec8102007224a6 (https://code.djangoproject.com/ticket/27018).
As a work-around, __qualname__
can be manually defined on Feed objects:
class MyFeed(Feed): def __init__(self): super().__init__() self.__qualname__ = self.__class__.__name__
Without knowing Django's opinion of the use of callable objects as views, I don't know the appropriate way to fix this: Should admindocs support callable objects as views, or should Feed not use a callable object as a view?
Change History (3)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|
comment:3 by , 7 years ago
Description: | modified (diff) |
---|