Laxmikant Gurnalkar
unread,Sep 27, 2012, 4:58:49 AM9/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi ,
While storing decimal values to database I have following error.
Exception in storeFormatMetadataTraceback (most recent call last):
File "/var/opt/igp_acfs/acfs/bookproducts_manager.py", line 118, in storePricing
book.save()
File "/var/opt/igp_acfs/acfs/models.py", line 529, in save
super(BookProductFormat, self).save()
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 458, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 524, in save_base
rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 502, in _update
return query.get_compiler(self.db).execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 866, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 722, in execute_sql
sql, params = self.as_sql()
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 831, in as_sql
val = field.get_db_prep_save(val, connection=self.connection)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 276, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 271, in get_db_prep_value
value = self.get_prep_value(value)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 876, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: ''
This is my code :
obj = Model.objects.get(uid = formatuid)
obj.price = Decimal(price).quantize(Decimal('.01'), rounding='ROUND_DOWN')
obj.active = 1 if formats.get(format, "")else 0
obj.save()
This is my mdel Field
price = models.DecimalField(max_digits=3, decimal_places=2, blank=True, null=True)
I dont think. I'm wrong somewhere. Please HELP
Obviously price is my decimal Field.
Best Regards,
Laxmikant