如何解决如何正确编写 django 辅助函数以检查新行以及数据是否已更改?
我正在尝试在 Django 中编写两个函数作为助手,它可以帮助我检查是否有新数据到来或现有数据是否已更改以进行进一步更新
is_new_row - will understand if the row is new and add it to an array that will be bulk created
is_data_modified - will look for the row in the old data and understand if the data of that row is changed and will update only if its changed
old_data = Person.objects.all()
for row in api_data:
if is_new_row(row,old_data):
new_rows_array.append(row)
else:
if is_data_modified(row,old_data):
...
# do the update
else:
continue
帮手
def is_new_row(row,old_data):
??
def is_data_modified(row,old_data):
??
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。