Re: Query with GeoDjango

2012-07-01 Thread Emiliano M. Rudenick
El Sat, 30 Jun 2012 17:18:27 -0700 (PDT)
Odagi  escribió:
> class Restaurant(models.Model):
> place = models.OneToOneField(Place, primary_key=True)
> serves_hot_dogs = models.BooleanField()
> serves_pizza = models.BooleanField()

Use GeoManager in your Restaurant model:

class Restaurant(models.Model):
place = models.OneToOneField(Place, primary_key=True)
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()
objects = geomodels.GeoManager()

Greatings!

-- 
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: Query with GeoDjango

2012-07-01 Thread Jani Tiainen
I thought that it was fixed along with
https://code.djangoproject.com/ticket/12344 ... Bascially it aoubt that
Django picks "origin manager" to be used in related models (and thus
related model manager) as well and that seem to cause queries to fail.



On Sun, Jul 1, 2012 at 3:42 AM, Ethan Jucovy  wrote:

> On Sat, Jun 30, 2012 at 8:31 PM, Odagi  wrote:
>
>> It's working! Thanks a lot.
>> Is There a problem with mixing regular models fields with geomodels ones?
>>
>
> No, there's no problem, as long as you remember to use a GeoManager on
> every model that ever does geospatial queries (whether or not it has any
> geospatial fields itself)
>
> -Ethan
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Query with GeoDjango

2012-06-30 Thread Ethan Jucovy
On Sat, Jun 30, 2012 at 8:31 PM, Odagi  wrote:

> It's working! Thanks a lot.
> Is There a problem with mixing regular models fields with geomodels ones?
>

No, there's no problem, as long as you remember to use a GeoManager on
every model that ever does geospatial queries (whether or not it has any
geospatial fields itself)

-Ethan

-- 
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: Query with GeoDjango

2012-06-30 Thread Odagi
It's working! Thanks a lot. 
Is There a problem with mixing regular models fields with geomodels ones?


The single underscore is correct: 
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#distance-lte
>
> But, you need to use a `objects = GeoManager()` on the Restaurants model 
> (as well as the Place model) per the docs: 
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeoManager
>
>  -Ethan
>

-- 
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/-/4FdC-Q1mfuUJ.
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: Query with GeoDjango

2012-06-30 Thread Ethan Jucovy
On Sat, Jun 30, 2012 at 8:19 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Try a double underscore between distance and lte.
>

The single underscore is correct:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#distance-lte

But, you need to use a `objects = GeoManager()` on the Restaurants model
(as well as the Place model) per the docs:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeoManager

 -Ethan


> _Nik
>
> On 6/30/2012 5:18 PM, Odagi wrote:
> > Hello all. I'm wondering how to resolve this problem with a
> > GeoDjango.This are my models:
> >
> >
> > from django.db import models
> > from django.contrib.gis.db import models as geomodels
> > from django.contrib.gis.geos import Point
> > from django.contrib.gis.measure import D
> >
> > class Place(geomodels.Model):
> > name = models.CharField(max_length=50)
> > point = geomodels.PointField(null=True)
> > objects = geomodels.GeoManager()
> >
> > def __unicode__(self):
> > return u"%s the place" % self.name
> >
> >
> > class Restaurant(models.Model):
> > place = models.OneToOneField(Place, primary_key=True)
> > serves_hot_dogs = models.BooleanField()
> > serves_pizza = models.BooleanField()
> >
> > def __unicode__(self):
> > return u"%s the restaurant" % self.place.name
> >
> >
> >
> > How can I get all Restaurants that serve pizza in a radio of 45km of a
> > given (geolocation) point?
> > I'm trying something like:
> >
> > pnt = Point(-34.5875015259, -58.6725006104)
> > Restaurant.objects.all().filter(place__point__distance_lte=(pnt,
> > D(km=45)))
> >
> > But it's not working:
> > Join on field 'point' not permitted. Did you misspell 'distance_lte' for
> the lookup type?
> >
> > Any ideas?
> > Thanks in advance.
> >
> >
> >
> >
> > --
> > 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/-/eGmII8v1GMMJ.
> > 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.
>
>

-- 
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: Query with GeoDjango

2012-06-30 Thread Nikolas Stevenson-Molnar
Try a double underscore between distance and lte.

_Nik

On 6/30/2012 5:18 PM, Odagi wrote:
> Hello all. I'm wondering how to resolve this problem with a
> GeoDjango.This are my models:
>
>
> from django.db import models
> from django.contrib.gis.db import models as geomodels
> from django.contrib.gis.geos import Point
> from django.contrib.gis.measure import D
>
> class Place(geomodels.Model):
> name = models.CharField(max_length=50)
> point = geomodels.PointField(null=True)
> objects = geomodels.GeoManager()
>
> def __unicode__(self):
> return u"%s the place" % self.name
>
>
> class Restaurant(models.Model):
> place = models.OneToOneField(Place, primary_key=True)
> serves_hot_dogs = models.BooleanField()
> serves_pizza = models.BooleanField()
>
> def __unicode__(self):
> return u"%s the restaurant" % self.place.name
>
> 
>
> How can I get all Restaurants that serve pizza in a radio of 45km of a
> given (geolocation) point?
> I'm trying something like:
>
> pnt = Point(-34.5875015259, -58.6725006104)
> Restaurant.objects.all().filter(place__point__distance_lte=(pnt,
> D(km=45)))
>
> But it's not working:
> Join on field 'point' not permitted. Did you misspell 'distance_lte' for the 
> lookup type?
>
> Any ideas?
> Thanks in advance.
>
>
>
>
> -- 
> 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/-/eGmII8v1GMMJ.
> 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.