def to_representation(self, value): if isinstance(value, dict) or value is None: return value value = HStoreDict(value) return value
def to_native(self, value): if isinstance(value, dict) or value is None: return value value = HStoreDict(value) return value
def clean_attributes(self, attributes): cleaned = {} for key in attributes.keys(): val = attributes[key] if isinstance(val, (datetime.datetime, datetime.date)): val = val.isoformat() cleaned[key] = val return HStoreDict(cleaned)
def to_internal_value(self, value): if value: try: return HStoreDict(value) except HStoreDictException as e: raise ValidationError( _('Invalid JSON: %s' % e.json_error_message)) else: return None
def to_internal_value(self, data): return HStoreDict(data)