1, I ran into this anomaly in updating a decimal field: The field:
remaining = models.DecimalField(max_digits=8, decimal_places=2, default=Decimal("0")) The code that failed: 658 self.remaining -= qty 659 self.remaining = max([Decimal("0"), self.remaining]) 660 self.save() The error message: TypeError unsupported operand type(s) for -=: 'unicode' and 'Decimal' models.py in update_from_transaction, line 658 The workaround: remaining = Decimal(self.remaining) remaining -= qty self.remaining = max([Decimal("0"), remaining]) self.save() So, what gives? Is this an example of this bug? http://code.djangoproject.com/ticket/5903 (P.S. the object being updated had been saved before the code in error ran. In other words, the error happened in a re-update of a previously saved object.) 2. This changeset says it has fixed ticket #5903: http://code.djangoproject.com/changeset/9823 Also says it was fixed 6 months ago. I did not find the ticket listed in any of the milestones in the last 6 months, and the page does not list a milestone. Does that mean it has not been included in any release, and awaits 1.2? 3. Also, what is the best practice for specifying a DecimalField default? I did some googling and found code using default="0", default=Decimal(0), default=Decimal("0"), and default=Decimal("0.0"). I did some tests and they all seem to work. --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---