【发布时间】:2018-01-13 07:32:42
【问题描述】:
我读过 mixin 并且明白 mixin 是一种特殊的多重继承,并为一个类提供了很多可选的特性。 现在我想知道什么是 JsonResponseMixin 以及为什么使用它们。
class JsonResponseMixin(object):
def render_to_json_response(self,context,**response_kwargs):
return JsonResponse(context,**response_kwargs)
def get_data(self,context):
return context
这是我在 mixin.py 中找到的代码。有人能解释一下为什么使用它吗。它们用于序列化数据吗?请详细说明
【问题讨论】: