Hi

I am trying to create a metadata field for documents that has some other 
metadata field.

When the code is run as a command, it runs most of the time, but then in 
some cases it gets "maximum recursion level reached" with the following 
logs:

lock_manager.managers <29572> [DEBUG] "acquire_lock() trying to acquire 
lock: document_indexing_task_do_rebuild_all_indexes"

lock_manager.managers <29572> [DEBUG] "acquire_lock() IntegrityError: 
duplicate key value violates unique constraint "lock_manager_lock_name_key"

DETAIL:  Key (name)=(document_indexing_task_do_rebuild_all_indexes) already 
exists.


What is the correct way of doing bulk metadata updates without running into 
the above problems?

The code is as follows:

from documents.models import Document
from metadata.models import MetadataType

class Command(BaseCommand):
    def handle(self, *args, **options):
        docs = Document.objects.all()
        for doc in docs:
            if doc.metadata.filter(metadata_type__name='field1').exists():
                md = MetadataType.objects.get(name="field2")
                doc.metadata.create(metadata_type=md,value="123")

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to