On Fri, May 16, 2008 at 1:57 PM, Szaijan <[EMAIL PROTECTED]> wrote: > > Thanks Karen. > > Actually, the behavior here is worst case, from my perspective, in > that Ture/False values will update an instance, but will not be saved > and no exception is thrown. When I try to update the model with a > True/False value, it simply fails to update without giving any > indication of an error. > > So, on my Slicehost installation (MySQL based): > > m = Model.object.get(id=id) > print m.BooleanField // Prints 0, if the value is False > m.BooleanField = True > m.save() > print m.BooleanField // Prints True > m = Model.object.get(id=id) > print m.BooleanField // Still prints 0. The instance was > updated, but did not save. No error. > m.BooleanField = 1 > m.save() > print m.BooleanField // Prints 1 > m = Model.object.get(id=id) > print m.BooleanField // Now prints 1. Saved correctly. > > I have to alter my code so 0 and 1 are submitted to get updates to > save correctly. I am not pulling anything through SQL, only directly > through the Django models. This sounds like a bug to me, but I want > to be sure there's not some MySQL boolean setting that I might be > missing in my settings.py, or even in my MySQL setup files. >
That does sound like a bug, but I cannot recreate it: (InteractiveConsole) >>> import django >>> django.get_version() u'0.97-pre-SVN-7511' >>> from crossword.models import Entries >>> e1 = Entries.objects.get(pk=2222) >>> e1.Exclude 0 >>> e1.Exclude=True >>> e1.save() >>> e1.Exclude True >>> e2 = Entries.objects.get(pk=2222) >>> e2.Exclude 1 >>> So, in my case, I can use True to update a boolean field and it does get saved to the database (though it still gets shown as 1 except for the exact model instance where I changed it). What level of django, mysqldb, etc. are you using? Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" 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-users?hl=en -~----------~----~----~----~------~----~------~--~---

