Changes between Initial Version and Version 1 of Ticket #28696, comment 2


Ignore:
Timestamp:
Oct 10, 2017, 6:18:20 PM (7 years ago)
Author:
Geoffrey Fairchild

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28696, comment 2

    initial v1  
    1 Replying to [comment:1 Simon Charette]:
    2 > The reason why you can't filter against `GeometryType` is simply that this lookup have not been aded yet.
    3 >
    4 > In the mean time you could use the expression API to achieve the same thing without relying on `extra()`.
    5 >
    6 > {{{#!python
    7 > from django.db.models import CharField, Func
    8 >
    9 > class GeometryType(Func):
    10 >     function = 'GeometryType'
    11 >     output_field = CharField()
    12 >
    13 > LocationBorder.objects.annotate(
    14 >     geom_type=GeometryType('geometry'),
    15 > ).filter(
    16 >     geom_type__in={'POLYGON', 'MULTIPOLYGON'},
    17 > )
    18 > }}}
    19 
    201Nice! This is cleaner than what I'm currently doing.
Back to Top