开发者

Creation of a django model instance not working on a custom management command

开发者 https://www.devze.com 2023-01-25 16:03 出处:网络
I\'m trying to create a new instance of one of my Django models. When I do it in my python shell it works fine and the object is indeed created.

I'm trying to create a new instance of one of my Django models. When I do it in my python shell it works fine and the object is indeed created.

However, when I do it in one of my custom management commands' script using the exact same code, there is no error but the object is never created开发者_如何学编程!!

Any ideas?


ok, solved it.

I used a keyboard interrupt to exit the script, and I'm guessing the script needs to exit correctly in order to finish the db transaction. I let it exit on itself and the objects were created.

0

精彩评论

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