Manually Calling A Class Based Generic View
I'm currently trying to call a class based Generic view from within another class based generic view and cant seem to do it correctly. Ways I've tried: result = CategoryTypes.as_vi
Solution 1:
The first way -- CategoryTypes.as_view()(self.request) -- is right. The problem is that if your view returns a TemplateResponse, its render method isn't called automatically.
So if you need to access the content of the response, call render() on it first.
Solution 2:
Or you can directly access just content via result.rendered_content. Before making this be sure you will set session into your request before passing into a view:
self.request.session = {}
CategoryTypes.as_view()(self.request)
Post a Comment for "Manually Calling A Class Based Generic View"