标签:library key from reg rom 日期 pre 编写 imp
1.编写过滤器函数myfilter.py
# -*- coding: utf-8 -*- from django import template register = template.Library() # 定义一个将日期中的月份转换为大写的过滤器,如8转换为八 @register.filter def month_to_upper(key): return [‘一‘, ‘二‘, ‘三‘, ‘四‘, ‘五‘, ‘六‘, ‘七‘, ‘八‘, ‘九‘, ‘十‘, ‘十一‘, ‘十二‘][key.month-1]
2.页面
{% load myfilter %} <div class="month">{{ bean.create_date | month_to_upper }}</div>
标签:library key from reg rom 日期 pre 编写 imp
原文地址:http://www.cnblogs.com/413xiaol/p/6853636.html