[Answered ]-Replacing object_list with ListView: AttributeError

2👍

You don’t say so, but you seem to be using the generic views at the end of an existing view. You wouldn’t normally do that with a class-based generic view: the whole point of them being classes is that you can extend them by subclassing, adding your own functionality that way.

However, you can probably fix your immediate error in the short term by actually calling the view: what you are doing here is simply creating the view object (which itself is a callable). You still need to call that object, passing it the request and any params:

view = ListView.as_view(template_name='generic_list.html')
return view(request, *args, **kwargs)

But as I say I do not recommend doing that: you should subclass ListView and extend it.

Leave a comment