Django Boolean is "True" after migration and not selected in ModelForm
I am trying to add a row to my Model and have that option editable in a ModelForm in Django. I want the field to be True by default. Here's what I'm adding to my model:
field_name = models.BooleanField(default=1)
Then, I use South to do a migration. Everything works perfectly, except instead of my database full of "1" for this field, it's full of "True" and for some reason, when it pu开发者_如何学Golls up the ModelForm, the checkbox isn't checked when "True". When I change "True" to "1" in the database, it is checked.
Trying to find a good solution here. Seems odd.
Have you tried this.
field_name = models.BooleanField(default=True)
What database are you using, does your database support Boolean fields? Or does it use a smallint field with 0 and 1 for false and true?
精彩评论