On Thu, Feb 19, 2009 at 5:24 AM, Alfonso <allanhender...@gmail.com> wrote:

>
> Karen,
>
> Good point - I will certainly use dpaste in the future.  Here's the
> traceback, I should have copied that in right from the start:
>
> Traceback:
> [snip]

File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/
> admin/options.py" in save_model
>  376.         obj.save()
> File "/home/queryclick/webapps/django/bullet/invoices/models.py" in
> save
>  79. #      self.customer.outstanding_amount = Decimal('100.00')


This line points to outstanding_amount being the troublesome field.  I find
it a little odd that the line appears to be commented out in the traceback,
but no doubt there is some obvious explanation for that which is escaping me
at the moment.

[snip]

>

File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/
> fields/__init__.py" in get_db_prep_value
>  610.                 self.max_digits, self.decimal_places)
> File "/home/queryclick/webapps/django/lib/python2.5/django/db/backends/
> __init__.py" in value_to_db_decimal
>  345.         return util.format_number(value, max_digits,
> decimal_places)
> File "/home/queryclick/webapps/django/lib/python2.5/django/db/backends/
> util.py" in format_number
>  130.         return u'%s' % str(value.quantize(decimal.Decimal(".1")
> ** decimal_places, context=context))
>

>
> Exception Type: TypeError at /admin/invoices/customerinvoice/1/
> Exception Value: unsupported operand type(s) for ** or pow():
> 'Decimal' and 'NoneType'
>
>
And these combined with the message indicate the problem must be that
decimal_places for outstanding_amount is None, since the other argument
involved in the ** (decimal.Decimal(".1")) operation is clearly the
Decimal.  Looking back at your models shows that outstanding_field doesn't
have decimal_places (nor max_digits) specified.

Checking the doc, I was surprised to find that these are listed as
"optional" arguments, since I thought they were required.  In fact they are
required for syncdb -- if you try to run syncdb on a model specified as you
have your Customer, you will get:

Error: One or more models did not validate:
ttt.customer: "outstanding_amount": DecimalFields require a "decimal_places"
attribute.
ttt.customer: "outstanding_amount": DecimalFields require a "max_digits"
attribute.

So I think the doc is incorrect in listing these as optional.

Did you remove these parameters after creating your tables?  (If so, why?)
I think you need to put them back.

Karen

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

Reply via email to