Пример #1
0
    def delete(self, *args, **kwargs):
        primitive_instance_fields = self.fields.filter(
            value__model__in=MetaModel.get_primitive())

        for field in primitive_instance_fields:
            field.value.delete()

        return super(InstanceModel, self).delete(*args, **kwargs)
Пример #2
0
 def delete_non_used_primitives(cls):
     cls.objects.filter(model__in=MetaModel.get_primitive(),
                        fields_usage__isnull=True).delete()