I am running the django web server/sqlite on WinXP with Python 2.4 and
the latest django SVN version. In keeping up with the FloatField to
DecimalField changes I came across an error in both the admin pages
and user pages with one of my apps.
In the debug page (excellent feature), an InvalidOperation was being
raised at location "C:\Python24\lib\decimal.py in _raise_error, line
2267"
I traced the cause to some of my DecimalField values had empty string
values at some stage of the process. I have blank=True and null=True
on that field. A change to typecast_decimal function at line 96 of C:
\Python24\Lib\site-packages\django\db\backends\util.py solved the
problem.
def typecast_decimal(s):
    if s is None:
        return None
    return decimal.Decimal(s)
became:
def typecast_decimal(s):
    if s is None or s == '':  ### Change
        return None
    return decimal.Decimal(s)

I couldn't find anything on this subject in the ticket system. Could
someone advise whether this should be reported as a bug/enhancement?
In my situation, it is reasonable to make a null string and None
equivalent, but I wonder whether that can be generalised.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to