mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-04-18 06:01:01 +00:00
feat(eav): add bulk save functionality to Entity model
- Add `commit` parameter to `save` method - Implement `save_bulk` method for preparing bulk EAV Value objects - Modify `save` method to support bulk creation when `commit=False` - Update attribute value handling in `save` method
This commit is contained in:
parent
6a80a3a22c
commit
2fddeab56f
1 changed files with 6 additions and 4 deletions
|
|
@ -118,7 +118,9 @@ class Entity:
|
|||
if commit:
|
||||
attribute.save_value(self.instance, attribute_value)
|
||||
values[attribute.slug] = attribute_value
|
||||
self.save_bulk(values, attributes)
|
||||
if not commit:
|
||||
attributes_value = self.save_bulk(values, attributes)
|
||||
Value.objects.bulk_create(attributes_value)
|
||||
|
||||
def validate_attributes(self):
|
||||
"""
|
||||
|
|
@ -233,8 +235,8 @@ class Entity:
|
|||
|
||||
for attr_slug in attribute_slugs:
|
||||
entity_data = {
|
||||
"entity_ct": ct,
|
||||
"attribute": next(
|
||||
'entity_ct': ct,
|
||||
'attribute': next(
|
||||
(
|
||||
attribute
|
||||
for attribute in attributes
|
||||
|
|
@ -243,7 +245,7 @@ class Entity:
|
|||
None,
|
||||
),
|
||||
get_entity_pk_type(self): self.pk,
|
||||
"value": eav_values[attr_slug],
|
||||
'value': eav_values[attr_slug],
|
||||
}
|
||||
eav_values_to_create.append(Value(**entity_data))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue