fix transfer
This commit is contained in:
parent
05f5261668
commit
f87d891daa
|
|
@ -254,15 +254,17 @@ def transfer_guide_elements_bulk():
|
||||||
|
|
||||||
for guide in tqdm(Guide.objects.all(),
|
for guide in tqdm(Guide.objects.all(),
|
||||||
desc='update count_of_initial_objects field values'):
|
desc='update count_of_initial_objects field values'):
|
||||||
descendants = GuideElement.objects.get_root_node(guide).get_descendants()
|
root_node = GuideElement.objects.get_root_node(guide)
|
||||||
if descendants:
|
if root_node:
|
||||||
count_of_initial_objects = descendants.filter(
|
descendants = root_node.get_descendants()
|
||||||
guide_element_type__name__in=['EstablishmentNode', 'WineNode']).count()
|
if descendants:
|
||||||
guide.count_related_objects = count_of_initial_objects
|
count_related_objects = descendants.filter(
|
||||||
objects_to_update.append(guide)
|
guide_element_type__name__in=['EstablishmentNode', 'WineNode']).count()
|
||||||
|
guide.count_related_objects = count_related_objects
|
||||||
|
objects_to_update.append(guide)
|
||||||
|
|
||||||
# update count_of_initial_objects field values
|
# update count_of_initial_objects field values
|
||||||
Guide.objects.bulk_update(objects_to_update, ['count_objects_during_init', ])
|
Guide.objects.bulk_update(objects_to_update, ['count_related_objects', ])
|
||||||
print(f'COUNT OF UPDATED OBJECTS: {len(objects_to_update)}')
|
print(f'COUNT OF UPDATED OBJECTS: {len(objects_to_update)}')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user