Month list for a select drop down

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from mx.DateTime import *
from datetime import datetime

date = now()
month_ids = []
while not (date.month == 4 and date.year == 2004):
  month_ids.append((date.strftime('%b%y'),date.strftime('%B %Y')))
  date = date + RelativeDateTime(months=-1)

print month_ids
#date.days_in_month

More like this

  1. Handling choices the right way by mallipeddi 4 years, 6 months ago
  2. Model field choices as a namedtuple by whiteinge 1 year, 1 month ago
  3. In page edit object links by punteney 4 years, 1 month ago
  4. SelectDateWidget with format: day, month, year by zenx 2 years, 5 months ago
  5. DropDownMultiple widget by marinho 4 years ago

Comments

(Forgotten your password?)