我正在尝试修改Django表单以使用textarea而不是我家表单中“地址”字段的正常输入。文档似乎意味着这从Django 1.1(我正在使用)变为1.2。但这两种方法都不适合我。这是我尝试过的:
class HouseForm(forms.ModelForm):
address = forms.Textarea() # Should work with django 1.1, but doesn't
class Meta:
model = House
#widgets = { 'address': forms.Textarea() } # 1.2 style - doesn't work either.
答案 0 :(得分:4)
我认为需要将Textarea指定为小部件。
尝试
class HouseForm(forms.ModelForm):
address = forms.CharField(widget=forms.Textarea)
class Meta:
model = House