Django自定义simple_tag时出错如下:
解决办法:
在settings里的 加上红色的部分,my_tag为自定义的标签函数 后面的为其地址
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')] , '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', ], 'libraries':{ "my_tag":"app02.templates.my_tag", }, }, }, ]