Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default='False' is not reflected in django admin BooleanField when adding a new item

1) When I add new item in django admin site, all checkboxes are set to true, even if default is set to false.

2) If I don't touch any of them and save the item, when I reopen it to editing, all checkboxes are set to their apropriate values according the default (some true, some false).

3) If I uncheck and recheck some which should be false by default, it doesn't have any effect after reopening (it's false, like i didn't touch it).

4) If I uncheck some which should be true, it's value is saved (so it's false later)

5) When I later edit the values they ARE saved exactly as expected. no glitches.

Did you ever encounter similar glitches? Where was the problem?

(on django 1.3.1, python 2.6.6, sqlite3)

Something1 = models.BooleanField(default='False')
Something2 = models.BooleanField(default='True')
Something3 = models.BooleanField(default='False')

thanks

like image 233
tookanstoken Avatar asked Oct 23 '25 16:10

tookanstoken


1 Answers

You should pass a boolean value, not a string. In your case:

Something1 = models.BooleanField(default=False)
Something2 = models.BooleanField(default=True)
Something3 = models.BooleanField(default=False)
like image 66
dan-klasson Avatar answered Oct 25 '25 23:10

dan-klasson