开发者

Where do I put methods that perform create_if_missing or update_if_exists function in django?

In what location should I place methods that perform:

  • Create this row if it is missing
  • Update the row if it exists

for a django model ?

Additionally since I am using the default transaction scheme of django, this migh开发者_JAVA百科t introduce race conditions. How do I prevent that ?


Django has this built-in: get_or_create.


The answer is get_or_create.

I suppose it is obligatory to link to their docs as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜