[英]Python go through User fields
I have a celery task/for loop that should run through a specific list of user fields at the database but for some reason, I always get the error: 我有一个celery任务/ for循环,应该通过数据库中用户字段的特定列表运行,但是由于某些原因,我总是会收到错误消息:
... ...
tasks.py tasks.py
... Thanks for your help. ... 谢谢你的帮助。
all
is method and you should call it. all
都是方法,您应该调用它。
users = User.objects.all()
all()
returns QuerySet
which is iterable: https://docs.djangoproject.com/en/2.1/ref/models/querysets/#all all()
返回可迭代的QuerySet
: https : //docs.djangoproject.com/en/2.1/ref/models/querysets/#all
将User.objects.all
替换为User.objects.all()
Change you code to 将您的代码更改为
@periodic_task(run_every=(crontab(minute='*/1')), name="Check addr", ignore_result=True)
def check_addr():
users = User.objects.all()
for user in users:
print(user.acc_addr)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.