django的Form中添加属性

在ModelForm中添加新的属性

class AuthorForm(ModelForm):
    class Meta:
        model = Author
        widgets = {
            'name': TextInput(attrs={'placeholder': 'name'}),
        }

在Form的成员中添加属性

q = forms.CharField(label='search', 
                    widget=forms.TextInput(attrs={'placeholder': 'Search'}))

 

posted @ 2012-11-07 00:00  Mingxx  阅读(600)  评论(0编辑  收藏  举报