Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#11087 closed (fixed)

Filtering by Count aggregate does not work when using GeoManager

Reported by: David Gouldin Owned by: jbronn
Component: GIS Version: master
Severity: Keywords:
Cc: jdunck@…, dgouldin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Using the following models:

from django.contrib.gis.db import models

class Book(models.Model):
    name = models.CharField(max_length=100)
    objects = models.GeoManager()

class Author(models.Model):
    name = models.CharField(max_length=100)
    books = models.ForeignKey(Book, related_name="authors")
    objects = models.GeoManager()

Filtering on an annotated Count aggregate raises an AttributeError. Example:

>>> from mytestapp.models import Book, Author

>>> from django.db.models import Count

>>> Book.objects.annotate(num_authors=Count('authors')).filter(num_authors__gt=1)
...
<type 'exceptions.AttributeError'>: 'Count' object has no attribute 'alias'

Attachments (1)

11087.diff (954 bytes) - added by David Gouldin 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Jeremy Dunck

Cc: jdunck@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by David Gouldin

Cc: dgouldin@… added

Changed 7 years ago by David Gouldin

Attachment: 11087.diff added

comment:3 Changed 7 years ago by David Gouldin

Has patch: set
Needs tests: set

comment:4 Changed 7 years ago by jbronn

milestone: 1.1
Owner: changed from nobody to jbronn
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:5 Changed 7 years ago by jbronn

Resolution: fixed
Status: assignedclosed

(In [10912]) Fixed #11087 -- Fixed the Count annotation when used with GeoManager. Thanks to dgouldin for ticket and initial patch.

comment:6 Changed 7 years ago by ccahoon

(In [10993]) Fixed #11087 -- Fixed the Count annotation when used with GeoManager. Thanks to dgouldin for ticket and initial patch.

comment:7 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top