【发布时间】:2015-03-24 22:10:01
【问题描述】:
我昨天问过这个SO question。
我现在必须在我的 models.py 中显示选择列表的代码是:
YOB_TYPES = Choices(*(
((0, 'select_yob', _(' Select Year of Birth')),
(2000, 'to_present', _('2000 to Present'))) +
tuple((i, str(i)) for i in xrange(1990, 2000)) +
((1, 'unspecified', _('Prefer not to answer')),))
)
....
year_of_birth_type = models.PositiveIntegerField(choices=YOB_TYPES, default=YOB_TYPES.select_yob, validators=[MinValueValidator(1)])
....
现在显示选项列表,出生年份从 1990 年到 1999 年(升序)如下所示:
如何更改代码,使出生日期的年份显示为 1999 到 1990(降序),如下所示:
我已搜索但找不到与我的问题相关的任何内容 - 反转 ( .reverse() ) 元组输出 - 也许我正在搜索错误的主题。
【问题讨论】:
标签: django django-models django-1.7