diff --git a/chapter2/mysite/myapp/templatetags/myapp.py b/chapter2/mysite/myapp/templatetags/myapp.py index 490303e..bc8593e 100644 --- a/chapter2/mysite/myapp/templatetags/myapp.py +++ b/chapter2/mysite/myapp/templatetags/myapp.py @@ -3,7 +3,7 @@ from django import template register = template.Library() - +@register.simple_tag def present(val1, val2): """获取两个数的百分比,取整 val1 / val2 """ return int(val1 * 100 / val2) \ No newline at end of file