Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#11087 closed (fixed)

Filtering by Count aggregate does not work when using GeoManager

Reported by: dgouldin 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 dgouldin 6 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by jdunck

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

comment:2 Changed 6 years ago by dgouldin

  • Cc dgouldin@… added

Changed 6 years ago by dgouldin

comment:3 Changed 6 years ago by dgouldin

  • Has patch set
  • Needs tests set

comment:4 Changed 6 years ago by jbronn

  • milestone set to 1.1
  • Owner changed from nobody to jbronn
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 6 years ago by jbronn

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:6 Changed 6 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 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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