In my app model, I have a BooleanField:
campaign = models.BooleanField(default=False, db_index=True,
verbose_name=_('processed'), help_text=_('Campaign or not ?'))
I use this to distinguish between two things. So, I thought of sending this value as hidden from an html form:
<input type="hidden" name="campaign" value="True or False" />
but it seems that forms send strings and I want to convert that string into a Boolean. Of course, I can re-write the model, make it a CharField with a default='True or False' value, but that does not seem very elegant.
Is there a more djangoic way to do this?
All data in request.POST comes as strings or lists of strings. You need to convert it yourself or use django forms (preferred) which do the the work for you.
With django forms you can replace the widget when you initiate forms.BooleanField like this:
More info on django forms