##// END OF EJS Templates
If the first thread is created with not section existing yet, default tag will be added if it is the only one specified
If the first thread is created with not section existing yet, default tag will be added if it is the only one specified

File last commit:

r1404:fabf89e8 default
r1658:b924e5d9 default
Show More
cleantags.py
19 lines | 540 B | text/x-python | PythonLexer
from django.core.management import BaseCommand
from django.db import transaction
from django.db.models import Count
from boards.models import Tag
__author__ = 'neko259'
class Command(BaseCommand):
help = 'Removed tags that have no threads'
@transaction.atomic
def handle(self, *args, **options):
empty = Tag.objects.annotate(num_threads=Count('thread_tags'))\
.filter(num_threads=0).order_by('-required', 'name')
print('Removing {} empty tags'.format(empty.count()))
empty.delete()