From 435122d5a830abb706742f366cb8028657525e20 Mon Sep 17 00:00:00 2001 From: beckerfy <fynn.becker@hs-hannover.de> Date: Fri, 2 Nov 2018 13:35:33 +0100 Subject: [PATCH] Fix automagic django datetime parsing --- postgrestutils/client/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/postgrestutils/client/utils.py b/postgrestutils/client/utils.py index 6eae8d4..5daa063 100644 --- a/postgrestutils/client/utils.py +++ b/postgrestutils/client/utils.py @@ -38,9 +38,10 @@ def datetime_parser(json_dict): if DJANGO: try: parsed_dt = dateparse.parse_datetime(value) - if django_tz.is_naive(parsed_dt): - parsed_dt = django_tz.make_aware(parsed_dt) - json_dict[key] = parsed_dt + if parsed_dt: + if django_tz.is_naive(parsed_dt): + parsed_dt = django_tz.make_aware(parsed_dt) + json_dict[key] = parsed_dt except ValueError: pass # not a datetime, leave the string as it is else: -- GitLab