I have a form field like so
IS_EMPLOYED_CHOICES = (
('1', 'yes'), ('0', 'no')
)
class AddEmployee(forms.Form):
is_employed = forms.ChoiceField(choices=IS_EMPLOYED_CHOICES)
and the field in the model is a BooleanField
is_employed = models.BooleanField()
I am aware that a BooleanField is a varchar with either a '1' or '0' for True or False
However I want to pass this value from the model to the form field above so it would show no when it is False and yes when it is true.
emp_profile = Employees.objects.get(pk=1)
emp_form = AddEmployee(initial={
'is_employed' = emp_profile.is_employed
})
does not work
When the value actually comes out, it’s
TrueandFalseinstead of'1'and'0'.So you would do something like
and it should work