Manually calling a class based generic view

江枫思渺然 提交于 2019-12-03 23:58:53

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.

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!