def handle(self, *args, **kwargs):
        check_time = now() - timedelta(seconds=10)
        topics = Topic.objects.filter(created__lt=check_time)\
                      .annotate(counter=Count('posts'))\
                      .filter(counter=0)

        count = topics.count()
        print('Found %d invalid topics' % count)
        if count:
            answer = raw_input('Are you sure you want delete them? [y/n]:')
            if answer.lower() == 'y':
                print('Deleting topics')
                topics.delete()
                print('Deletion completed')
            else:
                print('Aborting')
dataset/ETHPy150Open hovel/pybbm/pybb/management/commands/pybb_delete_invalid_topics.py/Command.handle/original