1 2 3 4 5 6 7 8 9 10 11 | from django import template
import datetime
register = template.Library()
def age(bday, d=None):
if d is None:
d = datetime.date.today()
return (d.year - bday.year) - int((d.month, d.day) < (bday.month, bday.day))
register.filter('age', age)
|
More like this
- Humanized and localized timesince template filter by slink 2 years, 6 months ago
- table with n items per row using custom modulo tag by elgreengeeto 4 years, 5 months ago
- Make anything into a template by realmac 5 years, 3 months ago
- Sophisticated order_by sorting by mawi 5 months, 2 weeks ago
- urlize HTML by maguspk 2 years, 11 months ago
Comments
smart, thanks
#