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

自定义模板标签,使用时报以下错误

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',

            }
    },
},
]

猜你喜欢

转载自blog.51cto.com/zhangrf/2107991