コード例 #1
0
    def to_representation(self, value):
        if isinstance(value, dict) or value is None:
            return value

        value = HStoreDict(value)

        return value
コード例 #2
0
    def to_native(self, value):
        if isinstance(value, dict) or value is None:
            return value

        value = HStoreDict(value)

        return value
コード例 #3
0
 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)
コード例 #4
0
 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
コード例 #5
0
 def to_internal_value(self, data):
     return HStoreDict(data)