Well, both Django and Python are consistent in their use of the terms
"True" and "False" to represent boolean objects:
https://docs.djangoproject.com/en/dev/ref/models/fields/#booleanfield
http://docs.python.org/2/library/stdtypes.html#boolean-values
In addition, the whole point of the ORM is to
That seems to have worked... I used 1 and 0 as the database is set for a
tinyint to store the value (so needs to be 1 or 0). That said,
django/python seems to figure that out when saving the value.
Thanks; wouldn't have thought to try that.
On Saturday, 27 April 2013 14:46:14 UTC-4, Andrew Bol
Hi. May be you need
active = models.BooleanField(choices=((True,'yes'),(False,'no')))
?
- With regards, Andrei
2013/4/27 Marc R
> I've setup a boolean field and get it to display correctly using this in
> my model:
> active = models.BooleanField(choices=((1,'yes'),(0,'no')))
>
> However, whe
I've setup a boolean field and get it to display correctly using this in my
model:
active = models.BooleanField(choices=((1,'yes'),(0,'no')))
However, when I edit a record in the Django Admin, the select field always
shows "yes" regardless of the database value.
Saving "yes" or "no" stores the
4 matches
Mail list logo