मुझे लगता है कि आप किस समूह के सदस्य हैं, इसके आधार पर मुझे मेनू मेनू कस्टम चाहिए। Im Django 1.10.1, अलाउथ और इतने पर का उपयोग कर। जब im मेरे templatetag बनाने की कोशिश कर रहा है यह विफल रहता है और यह कहता है: my
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 error मेरे .html फ़ाइल में आती है जो कहती है,
{% load my_templatetag %}
मैंने लाखों बार सर्वर को पुनः आरंभ करने की कोशिश की है, मैंने भी सभी नामों को बदलने की कोशिश की है, और ऐप सेटिंग्स में INSTALLED_APPS का एक हिस्सा है। मैं क्या गलत कर रहा हूं?