在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'}))

 

相关文章:

  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2021-05-22
  • 2022-01-13
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案