NotImplementedError on BaseFOOView

Hello everyone!
Concerning #35682, do you think that abstract base views BaseFOOView should raise a NotImplementedError when they are not properly subclassed to provide a response. Or is it enough to just document usage and rely on the error:
YourView' object has no attribute 'render_to_response'.

Hi.

I think the generic class based views in Django are already perhaps overly complicated, and adding stub methods for all possible mixin usages would complicate that. Thus I’d be -1 to adding them.

From the issue, one should begin subclassing ListView, rather than BaseListView, until one has very specific reasons for doing otherwise. (At that point you’d be expected to know what mixins are required.)

1 Like

-1 to adding stub methods as well. I think it’s enough to document and rely on the existing error. The classes are already called out as “not intended to be used directly” so hand-holding not required.

(FYI, an alternative to stub methods is an __init_subclass__ method that looks for required method names/attributes. That can be used to provide feedback earlier than a stub method raising NotImplementedError, and doesn’t suffer the MRO issue discussed on the ticket. Not suggesting it here, just for future reference.)

2 Likes

I just made the PR of the changes needed Fixed #35682 -- Made Docstring updates in BaseDetailView and BaseList… by YashRaj1506 · Pull Request #18493 · django/django · GitHub, if we are not going with stub methods. @cliff688 and i discussed the minor changes and pushed the code.