Opened 15 years ago

Closed 15 years ago

Last modified 12 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: dev
Severity: Keywords:
Cc: jdunck@…, dgouldin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

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 15 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Jeremy Dunck, 15 years ago

Cc: jdunck@… added

comment:2 by David Gouldin, 15 years ago

Cc: dgouldin@… added

by David Gouldin, 15 years ago

Attachment: 11087.diff added

comment:3 by David Gouldin, 15 years ago

Has patch: set
Needs tests: set

comment:4 by jbronn, 15 years ago

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

comment:5 by jbronn, 15 years ago

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 by ccahoon, 15 years ago

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

comment:7 by Jacob, 12 years ago

milestone: 1.1

Milestone 1.1 deleted

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