Database update weirdness

9 views
Skip to first unread message

heidi

unread,
Feb 4, 2014, 8:33:09 AM2/4/14
to django...@googlegroups.com

I am developing a game in which the quantity of rebels updates after a turn change. Rebels are represented as integers from 0 to 100 in the (MySQL) database.

When I save, this happens:

print world.rebels
>>> 0

rebstab = 0
world.rebels += rebstab
world.save()

print world.rebels
>>> 0

However, when I use F() expressions (as I gather I should to prevent race conditions), this happens:

print world.rebels
>>> 0

rebstab = 0
world.rebels = F('rebels') + rebstab
world.save()

print world.rebels
>>> 100

What's going on?

Reply all
Reply to author
Forward
0 new messages