【发布时间】:2019-05-27 13:15:33
【问题描述】:
我有一个具有FloatRangeField 的模型
class Credit(models.Model):
interest_range = FloatRangeField('Interest', null=True, blank=True)
我有一个模型表格:
class CreditForm(forms.ModelForm):
interest_range = InclusiveFloatRangeField()
现在,我想指定 2 个固定小数位(仅在 UI 中,数据库检查不重要)
似乎models.FloatRangeField 不支持decimal_places。而且我在 django 文档中找不到任何示例来使用小部件为 FloatRangeField 指定小数位。
django 版本:2.2
【问题讨论】:
-
你能用 DecimalRangeField 代替吗?似乎这是实现目标的最简单选择:docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/…
-
@AlexK。它也不支持
decimal_places
标签: python django django-models django-forms