django中ModelForm中的bootstrap样式(继承即可)

  • Post author:
  • Post category:其他


class BootStrapForm:
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # {'title':对象,"percent":对象}
        for name, field in self.fields.items():
            field.widget.attrs['class'] = "form-control"
            field.widget.attrs['placeholder'] = "请输入{}".format(field.label)



版权声明:本文为b17361573847原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。