SystemConfig.objects.update_or_create(host_ip=host_ip, type=TYPE, defaults={'config': config})
# 相当于先去 get(host_ip=host_ip, type=TYPE) 如果存在更新 config
# 不存在 create(host_ip=host_ip, type=TYPE, config=config)
SystemConfig.objects.update_or_create(host_ip=host_ip, type=TYPE, defaults={'config': config})
# 相当于先去 get(host_ip=host_ip, type=TYPE) 如果存在更新 config
# 不存在 create(host_ip=host_ip, type=TYPE, config=config)
本文标题:update_or_create
本文链接:https://www.haomeiwen.com/subject/erdkeqtx.html
网友评论