project01
    thread

 project01
 thread
 threadfilters.py   from django.template import Library   register = Library()   @register.filter   def comment_filter(text):    return ''.join(list(map(convert_url, text.split('\n'))))   def convert_url(text_line):    # URLリンク行をaタグ付きの行に変換    if 'https://' in text_line or 'http://' in text_line:    return '<a href="' + text_line + '" target="_blank" rel="noopener noreferrer">' + text_line + '</a>'    else:    return text_line
 threadtags.py   from django.template import Library   from django.db.models import Count   from ..models import Category      register = Library()      @register.inclusion_tag('thread/tags/category_tag.html')   def categorytag():    ctx = {}    ctx['category_list'] = Category.objects.annotate(count=Count('topic')).order_by('sort')    return ctx