forms.py 文件源码

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

项目:gwells 作者: bcgov 项目源码 文件源码
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.layout = Layout(
            Fieldset(
                'Owner Information',
                Div(
                    Div('owner_full_name', css_class='col-md-4'),
                    css_class='row',
                ),
                Div(
                    Div('owner_mailing_address', css_class='col-md-4'),
                    css_class='row',
                ),
                Div(
                    Div('owner_city', css_class='col-md-3 city'),
                    Div('owner_province_state', css_class='col-md-1'),
                    Div('owner_postal_code', css_class='col-md-3 postal'),
                    css_class='row',
                ),
            )
        )
        super(WellOwnerForm, self).__init__(*args, **kwargs)
        # Make fields required on the form even though they are not required in the DB due to legacy data issues
        # TODO - check admin or staff user and don't make these fields required
        self.fields['owner_postal_code'].required = True

        # display code instead of the value from __str__ in the model
        self.fields['owner_province_state'].label_from_instance = self.label_from_instance_code
        try:
            bc = ProvinceState.objects.get(code='BC')
            self.initial['owner_province_state'] = bc
            self.fields['owner_province_state'].empty_label = None
        except Exception as e:
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号