Hieeeee,
              I have a problem in django decimal field query
execution. Here i have explained clearly about my problem.

Model
Class VehicleLocation:
             simno = models.DecimalField(max_digits=10,
decimal_places=0)
             latitude = models.DecimalField(max_digits=25,
decimal_places=16)
             longitude =models.DecimalField(max_digits=25,
decimal_places=16)

Sample data in table:
simno    longitude                                     latitude
  1           4545.0000000000000000         2493386.1000000000000000
  2           638936.0000000000000000
2745824.0000000000000000

1.Test.py
--------------------------
from decimal import *
def Location(request):
getcontext().prec = 16   # here make decimal precision length as 16
long=Decimal('2745824.0000000000000000')  # here 'long' data type is
<class 'decimal.Decimal'>
VehicleObject=VehicleLocation.objects.get(longitude=long)
print VehicleObject

Ouput:
 I am able to get the vehilcelocation object.
-----------------------------------------------------------------------------------------------------------

2.Error.py
-----------------------------------
from decimal import *
def Location(request):
getcontext().prec = 16   # here make decimal precision length
long=Decimal('2493386.1000000000000000 ')  # here 'long' data type is
<class 'decimal.Decimal'>
VehicleObject=VehicleLocation.objects.get(longitude=long)
print VehicleObject

Ouput:
error VehicleLocation matching query does not exist.
----------------------------------------------------------------------------------------------------

Issue:
        The issue which i found was when we give any value other than
zero after dot(1.1000000000000000), then query always fail. If we give
values  zero after dot(1.0000000000000000) then i am able to  get
output.

How can i overcome this problem?


Thanks & Regards,
Jayapal D
--~--~---------~--~----~------------~-------~--~----~
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