#35682: Clarify Base<FOO>View usage in docstrings.
-------------------------------------+-------------------------------------
Reporter: Jesús Leganés- | Owner:
Combarro | YashRaj1506
Type: | Status: assigned
Cleanup/optimization |
Component: Generic views | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by YashRaj1506):
Replying to [comment:3 Jesús Leganés-Combarro]:
> Adding the "Using this base class requires subclassing to provide a
response mixin" comment in the Docstring would be really nice, but in
addition to that, I would make it more explicit by adding an
implementation of `render_to_response()` that raise a
`NotImplementedError` exception, that at least would provide a more
specific message than a generic "object has no attribute" one.
>
> Besides that, although `render_to_response` is focused on templates, is
it also a good name for non-template-based Views? For example in my use
case I'm generating a dict object with a GeoJSON `FeaturesCollection`
object and later setting it as data of a `JsonResponse` object, there are
no templates involved at all.
Hey i am trying to solve this issue, i wanted to project this solution,
One way is that the `ListView` is inheriting from two classes called
`MultipleObjectTemplateResponseMixin` and `BaseListView` and
`MultipleObjectTemplateResponseMixin` inherits from
`TemplateResponseMixin`, which contains the function `render_to_response`
so eventually when `BaseListView.get()` is used in `ListView` the
`render_to_reponse` method is available there from
`MultipleObjectTemplateResponseMixin` and hence works with no problem, but
if the same thing happens while using `BaseListView` we will obviously get
error because `TemplateResponseMixin` is not inheritied. So one way is We
can add a docstring that this class(`BaseListView`) is meant to be
subclassed by `ListView`, so use `ListView` and let `BaseListView` be just
a base class meant to be inherited (we will raise a error too) .Would like
to know your opinion, accordingly i will make the pr.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35682#comment:6>