+class JSONAttributeDescriptor(AttributeFieldDescriptor):
+ def __set__(self, instance, value):
+ if self.field.key in instance._removed_attribute_registry:
+ instance._removed_attribute_registry.remove(self.field.key)
+ instance._added_attribute_registry[self.field.key] = value
+
+
+class ForeignKeyAttributeDescriptor(AttributeFieldDescriptor):
+ def __set__(self, instance, value):
+ if isinstance(value, (models.Model, type(None))):
+ if self.field.key in instance._removed_attribute_registry:
+ instance._removed_attribute_registry.remove(self.field.key)
+ instance._added_attribute_registry[self.field.key] = value
+ else:
+ raise AttributeError('The \'%s\' attribute can only be set using existing Model objects.' % self.field.name)
+
+
+class ManyToManyAttributeDescriptor(AttributeFieldDescriptor):
+ def __set__(self, instance, value):
+ if isinstance(value, models.QuerySet):
+ if self.field.key in instance._removed_attribute_registry:
+ instance._removed_attribute_registry.remove(self.field.key)
+ instance._added_attribute_registry[self.field.key] = value
+ else:
+ raise AttributeError('The \'%s\' attribute can only be set to a QuerySet.' % self.field.name)
+
+