我想要一个自定义的菜单,取决于你是哪个组的成员。 我使用 Django 1.10.1,allauth 等等。 当我试图让我的模板标签失败,它说:
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' looks like this:
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()
and tha error comes in my .html file which say,
{% load my_templatetag %}
我已经尝试重新启动服务器好几百万次了,我还尝试更改所有的名称,这个应用程序是 setings.py 中 INSTALLED _ APPS 的一部分。 我做错了什么?