1. 程式人生 > >is not a registered tag library. Must be one of:

is not a registered tag library. Must be one of:

django

自定義模板標簽,使用時報以下錯誤

TemplateSyntaxError at /my_customer_tags/
‘admin_tags‘ is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
cache
custom_tags
i18n
kingadmin_tags
l10n
log
static
staticfiles
tz

解決方法:
在proj.settings中做如下設置

TEMPLATES = [
{
    ‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
    ‘DIRS‘: [],
    ‘APP_DIRS‘: True,
    ‘OPTIONS‘: {
        ‘context_processors‘: [
            ‘django.template.context_processors.debug‘,
            ‘django.template.context_processors.request‘,
            ‘django.contrib.auth.context_processors.auth‘,
            ‘django.contrib.messages.context_processors.messages‘,
            ‘app.apptemplates.load_setting‘,

        ],

        ‘libraries‘:{
                        ‘my_customer_tags‘:  ‘yourapp.templatetags.my_customer_tags‘,

            }
    },
},
]

is not a registered tag library. Must be one of: