2012/9/27 Laxmikant Gurnalkar <laxmikant.gurnalkar@gmail.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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/K6k0jAEaxYcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment