[Solved]-Is django's ORM thread safe?

7👍

Yes,

Methods query, filter, get, exclude, etc. Return a new QuerySet object so the fundamental is done and you will get no problems doing Queries in a thread as it will always return a new object with no past references.

Disable the autocommit setup. You may be using more often transactions and the select_related method to avoid common thread problems like accessing rows at the same time.

I recommend you that always check your code will return a new QuerySet object and do not send querysets as arguments in functions and you will be Ok.

Leave a comment