Nah, didn't seem to work either. I ended up going with 
`.execute()`: 
https://docs.djangoproject.com/en/2.0/topics/db/sql/#executing-custom-sql-directly

On Sunday, January 7, 2018 at 11:49:16 PM UTC-5, Jani Tiainen wrote:
>
> Hi.
>
> __within is probably correct lookup. 
>
> You can find all lookups at:  
> https://docs.djangoproject.com/en/2.0/ref/contrib/gis/geoquerysets/
>
> 8.1.2018 2.36 "Tom Tanner" <dontsende...@gmail.com <javascript:>> 
> kirjoitti:
>
>> I get this error when trying Jani's example: "FieldError: Unsupported 
>> lookup 'inside' for MultiPolygonField or join on the field not permitted."
>>
>> On Sunday, January 7, 2018 at 7:33:51 PM UTC-5, Tom Tanner wrote:
>>>
>>> Thanks for replying, Jani. I should mention My `geom` field is a 
>>> MultiPolygon, so I can't use `from_bbox` it seems...
>>>
>>> On Sunday, January 7, 2018 at 3:45:55 AM UTC-5, Jani Tiainen wrote:
>>>>
>>>> Something like following should work. Didn't checked if that actually 
>>>> works.
>>>>
>>>> Mymodel.objects.filter(geom__inside=Polygon.from_bbox((x1,y1,x2,y2), 
>>>> srid=1234))   
>>>>
>>>> On Sun, Jan 7, 2018 at 10:41 AM, Jani Tiainen <red...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I didn't realize what you were asking for. :D
>>>>>
>>>>> Django has bunch of spatial queries, so you're looking some of those 
>>>>> __inside, __within lookups. Coordinate transformations do happen 
>>>>> automatically so you just need to provide srid for you "envelope".
>>>>>
>>>>> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner <dontsende...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> Here's a sample PostGIS query I use to get geometries within four 
>>>>>> points:
>>>>>>
>>>>>>     SELECT *
>>>>>>     FROM myTable
>>>>>>     WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, -
>>>>>> 97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.
>>>>>> geom,4326);
>>>>>>
>>>>>>
>>>>>> With this query, I can get all rows within those four points. How do 
>>>>>> I execute this query or similar queries in Django or GeoDjango?
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "Django users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to django-users...@googlegroups.com.
>>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/django-users/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/django-users/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Jani Tiainen
>>>>>
>>>>> - Well planned is half done, and a half done has been sufficient 
>>>>> before...
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/67a80f04-1ea1-45b7-bfce-76863ae0f13e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/67a80f04-1ea1-45b7-bfce-76863ae0f13e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b4623f71-52c7-4cd0-8dba-8e2e770875dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to