RE: using a models fields

2011-04-05 Thread Chris Matthews
Hi Jay,

I am no Geo expert but if you use the CharField then you can specify N/E/S/W 
(North/East/South/West) or + and - to control latitude & longitude. With the 
DecimalField you can only use the + and -.

BTW, Marty Alchin's book Pro Django (Chapter 5 page 118), shows a nice example 
to validate user input for latitude & longitude. He actually use the 
DecimalField and extends it with a clean method, checking that latitude values 
to fall in -90 to 90 & longitude values to fall in -180 to 180.

Regards
Chris


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of bishwendu kundu
Sent: 05 April 2011 02:41
To: django-users@googlegroups.com
Subject: Re: using a models fields

You can try saving the data as 
latitude=models.DecimalField(max_digits=7,decimal_places=4).Same for the 
longitude field.Here the max_digits takes into account both decimal and 
non-decimal places.All the data can be given in string form as it will be 
automatically converted to proper format as specified in your models for 
storing in database. I guess you will be using some criteria to extract data 
from the database...so,code can look like

list_of_XYZ()=XYZ.objects.filter(criteria)
for i in list_of_XYZ:
i.latitude,i.longitude ,i.zoomlevel
On Tue, Apr 5, 2011 at 1:45 AM, jay K. 
<jay.developer2...@gmail.com<mailto:jay.developer2...@gmail.com>> wrote:
Hello,

I got a couple of fields from a model I want to use

so the models.py looks like this

class XZY():

   latitude = models.CharField()
   longitude = models.CharField(.)
   zoomlevel = models.CharField()

I want to retrieve the data inside latitude, longitude and zoomlevel
to be able to create a static map for different locations, using google maps

How can I retrieve the fields data?

thanks
--
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<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: using a models fields

2011-04-04 Thread bishwendu kundu
You can try saving the data as
latitude=models.DecimalField(max_digits=7,decimal_places=4).Same for the
longitude field.Here the max_digits takes into account both decimal and
non-decimal places.All the data can be given in string form as it will be
automatically converted to proper format as specified in your models for
storing in database. I guess you will be using some criteria to extract data
from the database...so,code can look like

list_of_XYZ()=XYZ.objects.filter(criteria)
for i in list_of_XYZ:
i.latitude,i.longitude ,i.zoomlevel

On Tue, Apr 5, 2011 at 1:45 AM, jay K.  wrote:

> Hello,
>
> I got a couple of fields from a model I want to use
>
> so the models.py looks like this
> *
> class XZY():
>
>latitude = models.CharField()
>longitude = models.CharField(.)
>zoomlevel = models.CharField()*
>
> I want to retrieve the data inside latitude, longitude and zoomlevel
> to be able to create a static map for different locations, using google
> maps
>
> How can I retrieve the fields data?
>
> thanks
>
>  --
> 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.
>

-- 
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.