开发者

Django and "get() returned more than one Model name" error in multi-threaded program

开发者 https://www.devze.com 2022-12-22 23:37 出处:网络
Django\'s get_or_create function always cause \"get() returned more than one Model name\" error in a multi-threaded program.

Django's get_or_create function always cause "get() returned more than one Model name" error in a multi-threaded program.

I even tried to put get_or_create statement inside a lock.acquire() and lock.release() block but still didn't work.

The program only 开发者_运维知识库works when I set thread_count=1

The database is on InnoDB engine. How to fix this kind of problem?


This is not caused by multithreading, but because there are more than one object in database, that satisfies your query. You must select exactly one object from the database using get, otherwise it will raise an exception.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号