比如有一个 cbv ( Class-based views )
class MyView(View):
def get(self, request):
return HttpResponse('result')
然后想在另一个 fbv ( Function-based views )中调用上面的 get 结果,应该怎么做? 现在能想到的办法就是
def data_view(request):
content = MyView.as_view()(request).content
# do something
pass
感觉丑陋,有没有比较优雅的方法?
1
KgM4gLtF0shViDH3 2017-07-10 14:24:19 +08:00
持久化?
|