From 8443c2b14b2e36c4c633d5cb5f1780ef8c54018a Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 4 Jul 2019 11:46:12 +0200 Subject: Command: fix check model on process_pending_update --- ishtar_common/management/commands/process_pending_update.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/management/commands/process_pending_update.py b/ishtar_common/management/commands/process_pending_update.py index f0e908d42..6e97847cc 100644 --- a/ishtar_common/management/commands/process_pending_update.py +++ b/ishtar_common/management/commands/process_pending_update.py @@ -48,13 +48,12 @@ class Command(BaseCommand): continue if not bool( [True for k in model._meta.get_fields() - if k == "need_update"]): + if k.name == "need_update"]): continue msg = u"-> processing {}: ".format(model._meta.verbose_name) - ln = model.objects.count() - for idx, obj_id in enumerate( - model.objects.filter( - need_update=True).values('pk').all()): + q = model.objects.filter(need_update=True) + ln = q.count() + for idx, obj_id in enumerate(q.values('pk').all()): obj = model.objects.get(pk=obj_id['pk']) obj.skip_history_when_saving = True obj._no_move = True @@ -63,5 +62,5 @@ class Command(BaseCommand): sys.stdout.write(cmsg) sys.stdout.flush() obj.save() - if not quiet: + if not quiet and ln: sys.stdout.write("\n") -- cgit v1.2.3