QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
Simplified example to reproduce, with these models:
class State(models.Model):
name = models.CharField(max_length=100)
class Locality(models.Model):
name = models.CharField(max_length=100)
location = models.PointField(geography=True)
state = models.ForeignKey(State, on_delete=models.CASCADE)
Running the following code works fine in 2.0 (assuming you have a few models set up):
State.objects.annotate(distance=Distance('locality__location', Locality.objects.first().location))
But this code works in 1.11, and fails in 2.0.1 with TypeError: unhashable type: 'Point':
State.objects.annotate(distance=Distance('locality__location', self.locality.location)).annotate(count=Count('locality'))
Change History
(9)
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Cc: |
Ian Foote added
|
Severity: |
Normal → Release blocker
|
Summary: |
Unhashable type Point bug with multiple annotations → QuerySet with multiple annotations crashes with "unhashable type: 'Point'"
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → Bug
|
Cc: |
Mariusz Felisiak added
|
Owner: |
changed from nobody to Mariusz Felisiak
|
Status: |
new → assigned
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Bisected to 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.