| | 21 | |
|---|
| | 22 | def handle_field(self, obj, field): |
|---|
| | 23 | # A nasty special case: base YAML doesn't support serialization of time |
|---|
| | 24 | # types (as opposed to dates or datetimes, which it does support). Since |
|---|
| | 25 | # we want to use the "safe" serializer for better interoperability, we |
|---|
| | 26 | # need to do something with those pesky times. Converting 'em to strings |
|---|
| | 27 | # isn't perfect, but it's better than a "!!python/time" type which would |
|---|
| | 28 | # halt deserialization under any other language. |
|---|
| | 29 | if isinstance(field, models.TimeField) and getattr(obj, field.name) is not None: |
|---|
| | 30 | self._current[field.name] = str(getattr(obj, field.name)) |
|---|
| | 31 | else: |
|---|
| | 32 | super(Serializer, self).handle_field(obj, field) |
|---|
| | 33 | |
|---|