如何添加多个'在django ModelForm中输入的属性来获取:
<input id="id_photo_path" name="photo_path" type="file" multiple />.
有可能吗?我应该像这样使用widget
:
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ('text',)
widgets = {
'text': forms.Textarea(attrs={'class': 'form-control', 'rows': 3 }),
}
答案 0 :(得分:1)
试试这个:
from django import forms
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = {'photo_path',}
widgets = {
'photo_path': forms.ClearableFileInput(attrs={'multiple': True}),
}