2016-05-24 53 views
2

如何將「多」屬性添加到輸入在Django的ModelForm得到這個:如何在django modelForm中爲輸入type ='file'添加'multiple'屬性?

<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

試試這個:

from django import forms 

class CommentForm(forms.ModelForm): 
    class Meta: 
     model = Comment 
     fields = {'photo_path',} 
     widgets = { 
      'photo_path': forms.ClearableFileInput(attrs={'multiple': True}), 
     } 
相關問題