From a60d23ff998883159e15c84a2f436c9c5ae536e5 Mon Sep 17 00:00:00 2001 From: OdinsPlasmaRifle Date: Mon, 22 Feb 2021 15:34:01 +0200 Subject: [PATCH] Added new version of deepcopy handling --- drf_request_logging/mixins.py | 10 ++++++---- setup.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drf_request_logging/mixins.py b/drf_request_logging/mixins.py index becfccf..2309947 100644 --- a/drf_request_logging/mixins.py +++ b/drf_request_logging/mixins.py @@ -45,9 +45,10 @@ def get_body(self, body): def get_response(self, response): """ Get the response body with sensitive values masked. - """ - res = deepcopy(response).render() + Expects a rendered response. + """ + res = deepcopy(response) res.data = mask_and_clean_response_data(res.data) return res @@ -172,8 +173,9 @@ def finalize_response(self, request, response, *args, **kwargs): # Add new information about the request. self.new_request.user = user self.new_request.status_code = response.status_code - # Get a stored response to save on the database. - stored_response = self.get_response(response) + # Get a rendered and stored response to save on the database. + rendered_response = response.render() + stored_response = self.get_response(rendered_response) # TODO : Look into saving this as rendered data/text. # Pickle messes with the deepcopy functionality on models. self.new_request.response = pickle.dumps(stored_response) diff --git a/setup.py b/setup.py index 7fa476b..3f92e2d 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import find_packages, setup -VERSION = '0.0.14' +VERSION = '0.0.15' with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: README = readme.read()