0

如何在视图中使用 min_value 和 max_value?

例如,表格定义为:

class SomeForm(ModelForm):
    somefield = forms.IntegerField(min_value=1, max_value=10)

在我看来,我想做一些类似(伪代码)的事情:

min_value = somefield.min_value
4

1 回答 1

0

您可以在您的视图中执行此操作:

someform = SormForm() #you may instantiate differently.
sfield= someform.fields['somefield']
min_value = sfield.min_value
max_value = sfield.max_value
于 2012-08-02T05:31:23.463 回答