Re: BooleanField trouble
On Sep 12, 11:14 am, Jason <[EMAIL PROTECTED]> wrote: > yeah, that did work .. I'm just surprised I have to go through that > extra step now, when > before 1.0 release it seems I didn't have too :/ Great, but why would you think assigning a string to a Boolean field would work in the first place? Look at this from an interactive python session: >>> bool('true') True >>> bool('false') True >>> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: BooleanField trouble
yeah, that did work .. I'm just surprised I have to go through that extra step now, when before 1.0 release it seems I didn't have too :/ Anyways, thanks for the thoughts :) On Sep 12, 6:15 am, Gremmie <[EMAIL PROTECTED]> wrote: > On Sep 11, 11:55 pm, Jason <[EMAIL PROTECTED]> wrote: > > > > > I have a "true" or "false" string coming in from an ajax call to my > > view. I'm then turning around and directly assigning that string from > > the front end to my model object and saving it. > > > Before the upgrade to django 1.0, the database happily accepted my > > model object's value as 'true' or 'false' for that field when it was > > assigned and saved. I could see the value saved in the database as > > true/false ( I'm using sqlite ) > > > Now it seems that nothing but a 0 or 1 is saved correctly in the > > database for this BooleanField when its assigned to the model object > > from the html page. > > > Any ideas on this one? What are the boolean values supposed to be > > saved as in the database? What type of value should i be giving the > > model so that it will save correctly in the database ? > > I hate to ask the obvious, and I haven't tried this, but it would seem > you should assign Boolean values to a BooleanField. Did you try > converting the string to a boolean? Maybe with something like: field = > (s == 'true'). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: BooleanField trouble
On Sep 11, 11:55 pm, Jason <[EMAIL PROTECTED]> wrote: > I have a "true" or "false" string coming in from an ajax call to my > view. I'm then turning around and directly assigning that string from > the front end to my model object and saving it. > > Before the upgrade to django 1.0, the database happily accepted my > model object's value as 'true' or 'false' for that field when it was > assigned and saved. I could see the value saved in the database as > true/false ( I'm using sqlite ) > > Now it seems that nothing but a 0 or 1 is saved correctly in the > database for this BooleanField when its assigned to the model object > from the html page. > > Any ideas on this one? What are the boolean values supposed to be > saved as in the database? What type of value should i be giving the > model so that it will save correctly in the database ? I hate to ask the obvious, and I haven't tried this, but it would seem you should assign Boolean values to a BooleanField. Did you try converting the string to a boolean? Maybe with something like: field = (s == 'true'). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---