def convert(self, value):
        if isinstance(value, datetime):
            return value
        value = _to_string(value)
        if not value:
            if self.required:
                message = self.messages['required']
                if message is None:
                    message = self.gettext(u'This field is required.')
                raise ValidationError(message)
            return None
        try:
            return parse_datetime(value, tzinfo=self.tzinfo,
                                  date_formats=self.date_formats,
                                  time_formats=self.time_formats)
        except __HOLE__:
            message = self.messages['invalid_date']
            if message is None:
                message = self.gettext('Please enter a valid date.')
            raise ValidationError(message)
dataset/ETHPy150Open mitsuhiko/fungiform/fungiform/forms.py/DateTimeField.convert