def process_attribute_fields(sender, instance, created, **kwargs):
	if ATTRIBUTE_REGISTRY in instance.__dict__:
		registry = instance.__dict__[ATTRIBUTE_REGISTRY]
		instance.attribute_set.filter(key__in=[field.attribute_key for field in registry['removed']]).delete()
		
		for field in registry['added']:
			# TODO: Should this perhaps just use instance.attributes[field.attribute_key] = getattr(instance, field.name, None)?
			# (Would eliminate the need for field.value_class.)
			try:
				attribute = instance.attribute_set.get(key=field.attribute_key)
			except Attribute.DoesNotExist:
				attribute = Attribute()
				attribute.entity = instance
				attribute.key = field.attribute_key
			attribute.set_value(value=getattr(instance, field.name, None), value_class=field.value_class)
		del instance.__dict__[ATTRIBUTE_REGISTRY]
This function is attached to each :class:`Entity` subclass's post_save signal. Any :class:`Attribute`\ s managed by :class:`AttributeProxyField`\ s which have been removed will be deleted, and any new attributes will be created.
dataset/ETHPy150Open ithinksw/philo/philo/models/fields/entities.py/process_attribute_fields