Django2.0 自定义模板标签 assignment_tag 应该 改为 simple_tag

django by example 第三章报错:

@register.assignment_tag
AttributeError: ‘Library’ object has no attribute ‘assignment_tag’

 

AttributeError: 'Library' object has no attribute 'assignment_tag'

You may be seeing this error after upgrading to Django 2.0. This is because assignment_tag was deprecated in Django 1.9, and removed in Django 2.0:

Django 1.4 added the assignment_tag helper to ease the creation of template tags that store results in a template variable. The simple_tag() helper has gained this same ability, making the assignment_tag obsolete. Tags that use assignment_tag should be updated to use simple_tag.

from: https://blog.csdn.net/maizhaoxi/article/details/82719072

原文链接:,转发请注明来源!
评论已关闭。