Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguox/4de1a0cc586055d776be818ed636cf6e to your computer and use it in GitHub Desktop.
Save chrisguox/4de1a0cc586055d776be818ed636cf6e to your computer and use it in GitHub Desktop.
class ResponseMixin:
@property
def _base_result_dict():
result_dict = {
'res': 'Test'
}
return result_dict
class A(ResponseMixin, View):
def post(self, request, *args, **kwargs):
result_dict = self._base_result_dict
return JsonResponse(result_dict)
class B(ResponseMixin, View):
def post(self, request, *args, **kwargs):
result_dict = self._base_result_dict
res = result_dict.get("res")
result_dict["res"] = self._logic(res)
return JsonResponse(result_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment