Opened 7 years ago

Last modified 7 years ago

#29296 closed Bug

admindocs crash if a Feed is configured — at Initial Version

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

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 by falling back to view.__class__.__name__, but it appears that the Python 3 code in admindocs has never supported this. (https://github.com/django/django/blob/1.11.12/django/contrib/admindocs/views.py#L135)

As a work-around, __qualname__ can be manually defined on Feed objects:

class MyFeed(Feed):
    def __init__(self):
        super().__init__()
        self.__qualname__ = '__call__'

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 (0)

Note: See TracTickets for help on using tickets.
Back to Top