in my latest application I have models with like 15 Decimal fields,
with different decimal places.
when I try to save an object of that model, I get sometimes (often,
but not always) this error:
File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
item_copy
object.save()
File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
in save
File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
in save_base
File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 192, in get_db_prep_save
File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 609, in get_db_prep_value
File "/home/newt/django/1.0/lib/django/db/models/fields/
__init__.py", line 583, in to_python
File "/usr/lib/python2.5/decimal.py", line 650, in __new__
raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert Decimal("0.0000") to Decimal
It fails on the first decimal field (at it's only one with 4 decimal
places) and it just happens sometimes.
I remember something like that used to happen with psycopg2 some year
ago.
I think it breaks when it tries to get the data ready for the SQL
statement.
In this project I have to use django-pyodbc connector to MSSQL
database.
I have tried both 1.02 and 1.1b branches of the connector with same
errorous results.
It's the most frustrating bug in django so far, as I'm completely
helpless and even google's silent about this.
Please does anyone know what's causing this, or how to get rid of
it...
> in my latest application I have models with like 15 Decimal fields,
> with different decimal places.
> when I try to save an object of that model, I get sometimes (often,
> but not always) this error:
> File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> item_copy
> object.save()
> File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> in save
> File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> in save_base
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 192, in get_db_prep_save
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 609, in get_db_prep_value
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 583, in to_python
> File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> raise TypeError("Cannot convert %r to Decimal" % value)
> TypeError: Cannot convert Decimal("0.0000") to Decimal
> It fails on the first decimal field (at it's only one with 4 decimal
> places) and it just happens sometimes.
> I remember something like that used to happen with psycopg2 some year
> ago.
> I think it breaks when it tries to get the data ready for the SQL
> statement.
> In this project I have to use django-pyodbc connector to MSSQL
> database.
> I have tried both 1.02 and 1.1b branches of the connector with same
> errorous results.
> It's the most frustrating bug in django so far, as I'm completely
> helpless and even google's silent about this.
> Please does anyone know what's causing this, or how to get rid of
> it...
Hi,
I'm pretty sure I use it correctly, but don't understand how this
fixes the problem :(.
I looked up the reload in the documentation and all it does a module
reload - where would I place it?
I was thinking i could convert all decimals to strings prior the
saving the new object, but it would not fix updates.
Ales
On Apr 24, 8:45 pm, soniiic <soni...@gmail.com> wrote:
> On Apr 24, 3:37 pm, Newt <strejda.n...@gmail.com> wrote:
> > Hello,
> > in my latest application I have models with like 15 Decimal fields,
> > with different decimal places.
> > when I try to save an object of that model, I get sometimes (often,
> > but not always) this error:
> > File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> > item_copy
> > object.save()
> > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> > in save
> > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> > in save_base
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 192, in get_db_prep_save
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 609, in get_db_prep_value
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 583, in to_python
> > File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> > raise TypeError("Cannot convert %r to Decimal" % value)
> > TypeError: Cannot convert Decimal("0.0000") to Decimal
> > It fails on the first decimal field (at it's only one with 4 decimal
> > places) and it just happens sometimes.
> > I remember something like that used to happen with psycopg2 some year
> > ago.
> > I think it breaks when it tries to get the data ready for the SQL
> > statement.
> > In this project I have to use django-pyodbc connector to MSSQL
> > database.
> > I have tried both 1.02 and 1.1b branches of the connector with same
> > errorous results.
> > It's the most frustrating bug in django so far, as I'm completely
> > helpless and even google's silent about this.
> > Please does anyone know what's causing this, or how to get rid of
> > it...
> in my latest application I have models with like 15 Decimal fields,
> with different decimal places.
> when I try to save an object of that model, I get sometimes (often,
> but not always) this error:
> File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> item_copy
> object.save()
> File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> in save
> File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> in save_base
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 192, in get_db_prep_save
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 609, in get_db_prep_value
> File "/home/newt/django/1.0/lib/django/db/models/fields/
> __init__.py", line 583, in to_python
> File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> raise TypeError("Cannot convert %r to Decimal" % value)
> TypeError: Cannot convert Decimal("0.0000") to Decimal
> It fails on the first decimal field (at it's only one with 4 decimal
> places) and it just happens sometimes.
> I remember something like that used to happen with psycopg2 some year
> ago.
The psycopg2 problem was because the C extension module which is a
part of it wasn't implemented correctly so as to work in a Python sub
interpreter. The problems with that would only manifest when using
mod_python or mod_wsgi and application running in sub interpreter and
not main interpreter.
So, to start with, how are you hosting this application?
I'm running it as mod_python on Ubuntu 8.04 server. I connect to
external MSSQL server thru django-pyodbc, the only thing I had to
install manually was the pyodbc, the rest was installed using package
manager (unix-odbc, freetds). I'm not much a server admin and it was a
few months ago.
Ales
On Apr 25, 12:40 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
> On Apr 25, 12:37 am, Newt <strejda.n...@gmail.com> wrote:
> > Hello,
> > in my latest application I have models with like 15 Decimal fields,
> > with different decimal places.
> > when I try to save an object of that model, I get sometimes (often,
> > but not always) this error:
> > File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> > item_copy
> > object.save()
> > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> > in save
> > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> > in save_base
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 192, in get_db_prep_save
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 609, in get_db_prep_value
> > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > __init__.py", line 583, in to_python
> > File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> > raise TypeError("Cannot convert %r to Decimal" % value)
> > TypeError: Cannot convert Decimal("0.0000") to Decimal
> > It fails on the first decimal field (at it's only one with 4 decimal
> > places) and it just happens sometimes.
> > I remember something like that used to happen with psycopg2 some year
> > ago.
> The psycopg2 problem was because the C extension module which is a
> part of it wasn't implemented correctly so as to work in a Python sub
> interpreter. The problems with that would only manifest when using
> mod_python or mod_wsgi and application running in sub interpreter and
> not main interpreter.
> So, to start with, how are you hosting this application?
> Graham
> > I think it breaks when it tries to get the data ready for the SQL
> > statement.
> > In this project I have to use django-pyodbc connector to MSSQL
> > database.
> > I have tried both 1.02 and 1.1b branches of the connector with same
> > errorous results.
> > It's the most frustrating bug in django so far, as I'm completely
> > helpless and even google's silent about this.
> > Please does anyone know what's causing this, or how to get rid of
> > it...
> I'm running it as mod_python on Ubuntu 8.04 server. I connect to
> external MSSQL server thru django-pyodbc, the only thing I had to
> install manually was the pyodbc, the rest was installed using package
> manager (unix-odbc, freetds). I'm not much a server admin and it was a
> few months ago.
> Ales
> On Apr 25, 12:40 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
> wrote:
> > On Apr 25, 12:37 am, Newt <strejda.n...@gmail.com> wrote:
> > > Hello,
> > > in my latest application I have models with like 15 Decimal fields,
> > > with different decimal places.
> > > when I try to save an object of that model, I get sometimes (often,
> > > but not always) this error:
> > > File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> > > item_copy
> > > object.save()
> > > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> > > in save
> > > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> > > in save_base
> > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > __init__.py", line 192, in get_db_prep_save
> > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > __init__.py", line 609, in get_db_prep_value
> > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > __init__.py", line 583, in to_python
> > > File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> > > raise TypeError("Cannot convert %r to Decimal" % value)
> > > TypeError: Cannot convert Decimal("0.0000") to Decimal
> > > It fails on the first decimal field (at it's only one with 4 decimal
> > > places) and it just happens sometimes.
> > > I remember something like that used to happen with psycopg2 some year
> > > ago.
> > The psycopg2 problem was because the C extension module which is a
> > part of it wasn't implemented correctly so as to work in a Python sub
> > interpreter. The problems with that would only manifest when using
> > mod_python or mod_wsgi and application running in sub interpreter and
> > not main interpreter.
> > So, to start with, how are you hosting this application?
> > Graham
> > > I think it breaks when it tries to get the data ready for the SQL
> > > statement.
> > > In this project I have to use django-pyodbc connector to MSSQL
> > > database.
> > > I have tried both 1.02 and 1.1b branches of the connector with same
> > > errorous results.
> > > It's the most frustrating bug in django so far, as I'm completely
> > > helpless and even google's silent about this.
> > > Please does anyone know what's causing this, or how to get rid of
> > > it...
Thank you very much,
yes, it's the only app (well I have a production and development
version of the same application running there).
The production version is dj 1.0.2
The development version is dj 1.1b - with the trunk version of django-
pyodbc - but I switched to this version in desperate response to this
problem. I hope it's no problem.
Also i found this stuff in vhost configs:
PythonDebug On
PythonAutoReload On
So I commented these and added the interpreter directive. And now I'll
try it...
Ales
On Apr 25, 1:17 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
> Presuming you are only running the one web application on the server,
> do things improve it you add directive:
> PythonInterpreter main_interpreter
> to Apache configuration.
> If it doesn't, not the same issue as pyscopg2.
> Graham
> On Apr 25, 9:13 pm, Newt <strejda.n...@gmail.com> wrote:
> > I'm running it as mod_python on Ubuntu 8.04 server. I connect to
> > external MSSQL server thru django-pyodbc, the only thing I had to
> > install manually was the pyodbc, the rest was installed using package
> > manager (unix-odbc, freetds). I'm not much a server admin and it was a
> > few months ago.
> > Ales
> > On Apr 25, 12:40 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
> > wrote:
> > > > in my latest application I have models with like 15 Decimal fields,
> > > > with different decimal places.
> > > > when I try to save an object of that model, I get sometimes (often,
> > > > but not always) this error:
> > > > File "/home/newt/django/1.0/sites/cdms/item/views.py", line 1054, in
> > > > item_copy
> > > > object.save()
> > > > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 311,
> > > > in save
> > > > File "/home/newt/django/1.0/lib/django/db/models/base.py", line 371,
> > > > in save_base
> > > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > > __init__.py", line 192, in get_db_prep_save
> > > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > > __init__.py", line 609, in get_db_prep_value
> > > > File "/home/newt/django/1.0/lib/django/db/models/fields/
> > > > __init__.py", line 583, in to_python
> > > > File "/usr/lib/python2.5/decimal.py", line 650, in __new__
> > > > raise TypeError("Cannot convert %r to Decimal" % value)
> > > > TypeError: Cannot convert Decimal("0.0000") to Decimal
> > > > It fails on the first decimal field (at it's only one with 4 decimal
> > > > places) and it just happens sometimes.
> > > > I remember something like that used to happen with psycopg2 some year
> > > > ago.
> > > The psycopg2 problem was because the C extension module which is a
> > > part of it wasn't implemented correctly so as to work in a Python sub
> > > interpreter. The problems with that would only manifest when using
> > > mod_python or mod_wsgi and application running in sub interpreter and
> > > not main interpreter.
> > > So, to start with, how are you hosting this application?
> > > Graham
> > > > I think it breaks when it tries to get the data ready for the SQL
> > > > statement.
> > > > In this project I have to use django-pyodbc connector to MSSQL
> > > > database.
> > > > I have tried both 1.02 and 1.1b branches of the connector with same
> > > > errorous results.
> > > > It's the most frustrating bug in django so far, as I'm completely
> > > > helpless and even google's silent about this.
> > > > Please does anyone know what's causing this, or how to get rid of
> > > > it...
On Apr 25, 10:06 pm, Newt <strejda.n...@gmail.com> wrote:
> Thank you very much,
> yes, it's the only app (well I have a production and development
> version of the same application running there).
> The production version is dj 1.0.2
> The development version is dj 1.1b - with the trunk version of django-
> pyodbc - but I switched to this version in desperate response to this
> problem. I hope it's no problem.
> Also i found this stuff in vhost configs:
> PythonDebug On
> PythonAutoReload On
Commenting out PythonAutoReload will not make any difference as On is
the default for mod_python anyway. Also, that option has no bearing on
Django use anyway, and only applies to mod_python's own internal
module importer, which doesn't really get used in any way, at least to
load modules, when Django is being run.
> So I commented these and added the interpreter directive. And now I'll
> try it...
> Ales
> On Apr 25, 1:17 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
> wrote:
> > Presuming you are only running the one web application on the server,
> > do things improve it you add directive:
> > PythonInterpreter main_interpreter
> > to Apache configuration.
> > If it doesn't, not the same issue as pyscopg2.
> > Graham
> > On Apr 25, 9:13 pm, Newt <strejda.n...@gmail.com> wrote:
> > > I'm running it as mod_python on Ubuntu 8.04 server. I connect to
> > > external MSSQL server thru django-pyodbc, the only thing I had to
> > > install manually was the pyodbc, the rest was installed using package
> > > manager (unix-odbc, freetds). I'm not much a server admin and it was a
> > > few months ago.
> > > Ales
> > > On Apr 25, 12:40 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
> > > wrote:
> > > > > It fails on the first decimal field (at it's only one with 4 decimal
> > > > > places) and it just happens sometimes.
> > > > > I remember something like that used to happen with psycopg2 some year
> > > > > ago.
> > > > The psycopg2 problem was because the C extension module which is a
> > > > part of it wasn't implemented correctly so as to work in a Python sub
> > > > interpreter. The problems with that would only manifest when using
> > > > mod_python or mod_wsgi and application running in sub interpreter and
> > > > not main interpreter.
> > > > So, to start with, how are you hosting this application?
> > > > Graham
> > > > > I think it breaks when it tries to get the data ready for the SQL
> > > > > statement.
> > > > > In this project I have to use django-pyodbc connector to MSSQL
> > > > > database.
> > > > > I have tried both 1.02 and 1.1b branches of the connector with same
> > > > > errorous results.
> > > > > It's the most frustrating bug in django so far, as I'm completely
> > > > > helpless and even google's silent about this.
> > > > > Please does anyone know what's causing this, or how to get rid of
> > > > > it...