【发布时间】:2016-10-24 16:06:03
【问题描述】:
所以,我正在使用 Django update_or_create API 来构建我的表单数据。它工作正常...但是,一旦构建,我需要一种方法来检查哪些配置文件实际更新了,或者它们是否是第一次创建?
只是一个例子:
for people in peoples:
people, updated = People.objects.update_or_create(
id=people.person_id,
defaults={
'first_name': people.first_name,
}
)
过滤查询集:
people = People.objects.filter(
id__in=whatever,
)
但是,现在,我正在尝试通过创建或更新来过滤查询集...但没有看到用于该查询集的 API(例如,各种过滤器)
所以,我想做这样的事情:
updated = Person.objects.filter(updated=True, created_for_first_time=False)
and then I can write something like
if updated:
do this
else:
do this
基本上,我只想检查个人资料是否是第一次更新或创建。
【问题讨论】:
标签: python django django-queryset django-filter