#6696: saving boolean field
-----------------------+----------------------------------------------------
Reporter: imgrey | Owner: nobody
Status: new | Component: Core framework
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
Seems django behaves strange with boolean fields. Following is my
observations.
code:
{{{
"""
models.py:
class Thread(models.Model):
closed = models.BooleanField(default=False)
def save(self):
#...
super(Thread, self).save()
"""
import sys
sys.path.append('/home/grey/src/df')
from django.db import *
from board.models import Thread
thread = Thread.objects.all()[0]
print "IN:", thread.closed
thread.closed = not thread.closed
thread.save()
thread = Thread.objects.all()[0]
print "OUT:", thread.closed
}}}
outputs:
{{{
IN: True
OUT: True
IN: True
OUT: False
IN: False
OUT: False
}}}
detailed:
{{{
IN: True
[{'time': '0.002', 'sql': 'SELECT
"board_thread"."id","board_thread"."subject","board_thread"."forum_id","board_thread"."closed","board_thread"."csticky","board_thread"."gsticky","board_thread"."slug"
FROM "board_thread" LIMIT 1 '}, {'time': '0.026', 'sql': 'SELECT 1 FROM
"board_thread" WHERE "id"=2'}, {'time': '0.011', 'sql': 'UPDATE
"board_thread" SET
"subject"=\'mmnbmnbmnbmnbmnb\',"forum_id"=1,"closed"=false,"csticky"=false,"gsticky"=false,"slug"=\'mmnbmnbmnbmnbmnb\'
WHERE "id"=2'}]
OUT: True
[{'time': '0.002', 'sql': 'SELECT
"board_thread"."id","board_thread"."subject","board_thread"."forum_id","board_thread"."closed","board_thread"."csticky","board_thread"."gsticky","board_thread"."slug"
FROM "board_thread" LIMIT 1 '}, {'time': '0.026', 'sql': 'SELECT 1 FROM
"board_thread" WHERE "id"=2'}, {'time': '0.011', 'sql': 'UPDATE
"board_thread" SET
"subject"=\'mmnbmnbmnbmnbmnb\',"forum_id"=1,"closed"=false,"csticky"=false,"gsticky"=false,"slug"=\'mmnbmnbmnbmnbmnb\'
WHERE "id"=2'}, {'time': '0.001', 'sql': 'SELECT
"board_thread"."id","board_thread"."subject","board_thread"."forum_id","board_thread"."closed","board_thread"."csticky","board_thread"."gsticky","board_thread"."slug"
FROM "board_thread" LIMIT 1 '}]
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/6696>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---