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. FeaturedModelChoiceField by willhardy 3 years, 9 months ago
  2. DropDownMultiple widget by marinho 5 years ago
  3. Month / Year dropdown widget by gregb 3 years, 9 months ago
  4. Timezone choice field for select box by jmunro 1 year, 2 months ago
  5. CustomChoiceField, Selectable label field version of ModelChoiceField by mauro 5 years, 2 months ago

Comments

(Forgotten your password?)