Filtering by Count aggregate does not work when using GeoManager
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'
Has patch: |
set
|
Needs tests: |
set
|
milestone: |
→ 1.1
|
Owner: |
changed from nobody to jbronn
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
(In [10912]) Fixed #11087 -- Fixed the
Count
annotation when used withGeoManager
. Thanks to dgouldin for ticket and initial patch.