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')
)
评论列表
文章目录