(self, value)
| 24 | return value |
| 25 | |
| 26 | def to_python(self, value): |
| 27 | if not value: |
| 28 | return {} |
| 29 | if not isinstance(value, dict): |
| 30 | try: |
| 31 | value = json.loads(value) |
| 32 | except json.JSONDecodeError: |
| 33 | raise ValidationError( |
| 34 | self.error_messages["invalid_json"], |
| 35 | code="invalid_json", |
| 36 | ) |
| 37 | |
| 38 | if not isinstance(value, dict): |
| 39 | raise ValidationError( |
| 40 | self.error_messages["invalid_format"], |
| 41 | code="invalid_format", |
| 42 | ) |
| 43 | |
| 44 | # Cast everything to strings for ease. |
| 45 | for key, val in value.items(): |
| 46 | if val is not None: |
| 47 | val = str(val) |
| 48 | value[key] = val |
| 49 | return value |
| 50 | |
| 51 | def has_changed(self, initial, data): |
| 52 | """ |
no test coverage detected