3
I have
class Person(TimeStampedModel, Address):
name = models.CharField(_('nome'), max_length=100)
birthday = models.DateField(_('data de nascimento'))
and the function
import datetime
from datetime import date
'''
http://keyes.ie/calculate-age-with-python/
'''
def age(when, on=None):
if on is None:
on = datetime.date.today()
was_earlier = (on.month, on.day) < (when.month, when.day)
return on.year - when.year - (was_earlier)
age(date(2000, 1, 1))
How to count people by age range?
age quant
20-25 89
25-30 100
30-35 90
35-40 102
I know I have to use annottate and Count, but I don’t know where to start.