BootStrapForm组件

class BootStrapForm():
    bootstrap_exclude = []

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            if name in self.bootstrap_exclude:
                continue
            old_class = field.widget.attrs.get("class","")
            field.widget.attrs["class"] = "{} form-control".format(old_class)
            field.widget.attrs["placeholder"] = "请输入{}".format(field.label)

 

posted on 2020-05-04 12:07  仙人小麦  阅读(156)  评论(0编辑  收藏  举报