Converts from the Python type to the DB type. :param value: Current python value in model. :param instance: Model class or Model instance provided to look up. Due to metacoding, to determine if this is an instance reliably, please do a: .. code-blo
(self, value: Any, instance: type[Model] | Model)
| 296 | return result |
| 297 | |
| 298 | def to_db_value(self, value: Any, instance: type[Model] | Model) -> Any: |
| 299 | """ |
| 300 | Converts from the Python type to the DB type. |
| 301 | |
| 302 | :param value: Current python value in model. |
| 303 | :param instance: Model class or Model instance provided to look up. |
| 304 | |
| 305 | Due to metacoding, to determine if this is an instance reliably, please do a: |
| 306 | |
| 307 | .. code-block:: py3 |
| 308 | |
| 309 | if hasattr(instance, "_saved_in_db"): |
| 310 | """ |
| 311 | if value is not None and not isinstance(value, self.field_type): |
| 312 | value = self.field_type(value) # pylint: disable=E1102 |
| 313 | |
| 314 | self.validate(value) |
| 315 | return value |
| 316 | |
| 317 | def to_python_value(self, value: Any) -> Any: |
| 318 | """ |
no test coverage detected