def handle(self, *args, **options):
if options['username']:
users = list(User.objects.filter(username__in=options['username']))
usernames = {user.username for user in users}
if usernames != set(options['username']):
raise CommandError('User mismatch: couldn\'t find "{}"'.format(
'", "'.join(set(options['username']) - usernames)))
else:
users = list(User.objects.filter(is_active=True, email_verified=True))
for user in users:
self.stdout.write(user.username, ending=' ')
if not user.is_active or not user.email_verified:
self.stdout.write(self.style.WARNING('SKIP'))
continue
try:
self.send_update(user)
self.stdout.write(self.style.SUCCESS('OK'))
except Exception as ex:
self.stdout.write(self.style.ERROR('failed: {}'.format(repr(ex))))
评论列表
文章目录