あなたが所属するグループに応じてメニューをカスタマイズしたいのですが。 私はDjango 1.10.1、allauthなどを使用しています。 イムは私templatetagをしようとすると、それが失敗し、それが言う:¨Django 1.10.1 'my_templatetag'は登録されたタグライブラリではありません。
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()
とthaの誤差は、言う私の.htmlファイルで提供されます
{% load my_templatetag %}
私は私がすべての名前を変更しようとしました、そしてアプリはsettings.pyでINSTALLED_APPSの一部であり、また、数百万回のように、サーバーを再起動しようとしています。 私は何が間違っていますか?
ありがとう、マップ名でした! – Sliljedal