(self, value)
| 1954 | return "DurationField" |
| 1955 | |
| 1956 | def to_python(self, value): |
| 1957 | if value is None: |
| 1958 | return value |
| 1959 | if isinstance(value, datetime.timedelta): |
| 1960 | return value |
| 1961 | try: |
| 1962 | parsed = parse_duration(value) |
| 1963 | except ValueError: |
| 1964 | pass |
| 1965 | else: |
| 1966 | if parsed is not None: |
| 1967 | return parsed |
| 1968 | |
| 1969 | raise exceptions.ValidationError( |
| 1970 | self.error_messages["invalid"], |
| 1971 | code="invalid", |
| 1972 | params={"value": value}, |
| 1973 | ) |
| 1974 | |
| 1975 | def get_db_prep_value(self, value, connection, prepared=False): |
| 1976 | return connection.ops.adapt_durationfield_value(value) |
nothing calls this directly
no test coverage detected