Hey, sorry & thanks for reply. I had silly mistake.
In my following code
"format" was formatuid and obj.active is my integerField:
>>>> obj.active = 1 if formats.get(format, "")else 0
I changed later.
115 obj = Model.objects.get(uid = formatuid)
116 obj.price = Decimal(price).quantize(Decimal('.01'), rounding='ROUND_DOWN')
117 obj.active = 1 if formats.get(formatuid, "")else 0
118 obj.save() <<< Line no 118 (I was trying to hide my code, so book changed to obj. Not sure why!! :) )
Anyway,
Thanks again.
regards
On Thu, Sep 27, 2012 at 6:12 PM, Amyth Arora <aroras.official@gmail.com> wrote:
What other integer fields are there in your model ?--On Thu, Sep 27, 2012 at 2:35 PM, Sergey Fursov <geyser85@gmail.com> wrote:
As I see from the stack, error produced by book.save() in File "/var/opt/igp_acfs/acfs/bookproducts_manager.py", line 118 but in you code I can't this line of code. Do you really show the code, that related to error--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.
Thanks & Regards
----------------------------
Amyth [Admin - Techstricks]
Email - aroras.official@gmail.com, admin@techstricks.com
Twitter - @mytharora
http://techstricks.com/
--
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.
--
GlxGuru
--
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