forms.py 文件源码

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

项目:nav 作者: UNINETT 项目源码 文件源码
def __init__(self, *args, **kwargs):
        super(JustificationForm, self).__init__(*args, **kwargs)

        # Set correct helper text based on if this is an edit or add
        submit_value = 'Add reason'
        fieldset_legend = 'Add detention reason'
        if self.initial.get('justificationid'):
            submit_value = 'Save changes'
            fieldset_legend = 'Edit detention reason'

        # Create helper for crispy layout
        self.helper = FormHelper()
        self.helper.form_action = 'arnold-justificatons'
        self.helper.layout = Layout(
            Fieldset(
                fieldset_legend,
                'name', 'description', 'justificationid'
            ),
            Submit('submit', submit_value, css_class='small')
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号