I have this form:
class OrderSendForm(forms.Form):
MODEL_FIELD_MAPPING = {
'sent_to_metal_sector': 'metal_sector',
'sent_to_tailor_sector': 'tailor_sector',
'sent_to_upholstery_sector': 'upholstery_sector',
'sent_to_packing_sector': 'packing_sector',
'sent_to_loading_sector': 'loading_sector'
}
sectors = forms.MultipleChoiceField(
choices=(
('metal_sector', 'Sektor Metal'),
('tailor_sector', 'Sektor Šivaona'),
('upholstery_sector', 'Sektor Tapaciranje'),
('packing_sector', 'Sektor Pakovanje'),
('loading_sector', 'Sektor Utovar'),
),
widget=forms.CheckboxSelectMultiple,
)
How do I set the initial values for checkbox fields based on the value of corresponding model field. For example, if value of model field sent_to_metal_sector is True, then form field metal_sector should be checked when the form is rendered.