From d7b6ed36636f78c994b7b59dc4fa93e86a2b2b23 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Fri, 21 Apr 2023 13:14:34 +0100 Subject: [PATCH] If a date from the database is unparseable, use the raw string --- judgments/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/judgments/models.py b/judgments/models.py index 65bdbcf3f..a5b0f367b 100644 --- a/judgments/models.py +++ b/judgments/models.py @@ -2,6 +2,7 @@ from caselawclient.Client import api_client from dateutil import parser as dateparser +from dateutil.parser import ParserError from django.db import models from djxml import xmlmodels from ds_caselaw_utils.courts import CourtNotFoundException, courts @@ -25,7 +26,11 @@ def __init__( self.uri = uri self.neutral_citation = neutral_citation self.name = name - self.date = dateparser.parse(date) + + try: + self.date = dateparser.parse(date) + except ParserError: + self.date = date try: self.court = courts.get_by_code(court) except CourtNotFoundException: