【发布时间】:2020-08-06 09:25:17
【问题描述】:
表 SAPAdjustment 中的
列 acct_per_num 包含月份编号。以下代码提供了一个下拉列表,其中包含唯一月份编号 (1,2,3),列中存在于表 SAPAdjustment 的列 acct_per_num 但我想要月份名称(一月、二月、三月)而不是月份数字 (1,2,3)。
forms.py
class SAPReconForm(forms.Form):
month = forms.ModelChoiceField(queryset=SAPAdjustment.objects.values_list('acct_per_num',flat=True).distinct(), empty_label=None)
models.py
class SAPAdjustment(models.Model):
acct_per_num = models.IntegerField( blank=True,null=True, verbose_name =_('Month'),help_text=_('Month'))
我正在使用 python 2.7 和 django 1.6.7。
【问题讨论】:
标签: django django-models django-forms django-orm