yournextrepresentative
yournextrepresentative copied to clipboard
Partial ISO birth date raises ValidationError
Internal Server Error: /election/vouleftikes-ekloges-2016/person/create/
Traceback (most recent call last):
...
django.core.exceptions.ValidationError: {'start_date': ['date seems not to be correct 1984-06-00']}
...
POST:{'birth_date': '1984-06',
candidates.models.popolo_extra.parse_approximate_date appends a '-00' to partial dates which popolo.behaviors.models.validate_partial_date can't parse.
This appears to be attempting to insert the string representation of ApproximateDate into a CharField.
I've patched it up with
class WorseApproximateDate(ApproximateDate):
def __repr__(self):
repr_, *_ = super().__repr__().partition('-00')
return repr_
but then PersonExtra.dob_as_date can't parse it because
ValueError: day is out of range for month
and at this point I think I'm gonna need a drink ;)