TemplateSyntaxError at /
'my_templatetag' is not a registered tag library. Must be one of:
account
account_tags
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
socialaccount
socialaccount_tags
static
staticfiles
tz
'my_templatetag.py' 看起来像这样:
from django import template
from django.contrib.auth.models import Group
register = template.Library()
@register.filter(name='has_group')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return group in user.groups.all()
错误出现在我的 .html 文件中,提示如下:
{% load my_templatetag %}
我已经尝试了成千上万次重新启动服务器,还尝试更改所有名称,该应用程序也是settings.py中INSTALLED_APPS的一部分。我做错了什么?