diff --git a/apis_core/core/models.py b/apis_core/core/models.py index 317a04725..40a937813 100644 --- a/apis_core/core/models.py +++ b/apis_core/core/models.py @@ -30,41 +30,43 @@ class Meta: abstract = True def save(self, *args, **kwargs): - start = None - start_start = None - start_end = None - end = None - end_start = None - end_end = None + skip_date_parsing = getattr(self, "skip_date_parsing", False) + if not skip_date_parsing: + start = None + start_start = None + start_end = None + end = None + end_start = None + end_end = None - if self.start_date_written: - start, start_start, start_end = DateParser.parse_date( - self.start_date_written - ) - # DateParser returns datetime, but we want dates without time - if start: - start = start.date() - if start_start: - start_start = start_start.date() - if start_end: - start_end = start_end.date() + if self.start_date_written: + start, start_start, start_end = DateParser.parse_date( + self.start_date_written + ) + # DateParser returns datetime, but we want dates without time + if start: + start = start.date() + if start_start: + start_start = start_start.date() + if start_end: + start_end = start_end.date() - if self.end_date_written: - end, end_start, end_end = DateParser.parse_date(self.end_date_written) - # DateParser returns datetime, but we want dates without time - if end: - end = end.date() - if end_start: - end_start = end_start.date() - if end_end: - end_end = end_end.date() + if self.end_date_written: + end, end_start, end_end = DateParser.parse_date(self.end_date_written) + # DateParser returns datetime, but we want dates without time + if end: + end = end.date() + if end_start: + end_start = end_start.date() + if end_end: + end_end = end_end.date() - self.start_date = start - self.start_start_date = start_start - self.start_end_date = start_end - self.end_date = end - self.end_start_date = end_start - self.end_end_date = end_end + self.start_date = start + self.start_start_date = start_start + self.start_end_date = start_end + self.end_date = end + self.end_start_date = end_start + self.end_end_date = end_end super().save(*args, **kwargs)