forms.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:edd 作者: JBEI 项目源码 文件源码
def clean(self):
        data = super(WorklistDefaultsForm, self).clean()
        # this is SUPER GROSS, but apparently the only way to change the form output from here is
        #   to muck with the source data, by poking the undocumented _mutable property of QueryDict
        self.data._mutable = True
        # if no incoming data for field, fall back to default (initial) instead of empty string
        for name, field in self._created_fields.items():
            key = self.add_prefix(name)
            value = field.widget.value_from_datadict(self.data, self.files, key)
            if not value:
                value = field.initial
            self.data[key] = data[key] = value
            self._lookup[name].default_value = value
        # flip back _mutable property
        self.data._mutable = False
        return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号