def get_max_years():
"""
Determines the maximum number of available years to go back.
:return: the number of years
:rtype: int
"""
cursor = connection.cursor()
cursor.execute("""
select extract(year from min(start_date))
from %s
where start_date > '1900-01-01'
""" % StudentDates._meta.db_table)
min_year = None
max_years = None
for row in cursor.fetchall():
min_year = row[0]
if min_year is not None:
max_years = date.today().year - min_year
return int(max_years)
评论列表
文章目录