Opened 7 years ago
Last modified 7 years ago
#29054 closed Bug
Unhashable type Point bug with multiple annotations — at Initial Version
Reported by: | Lachlan Cannon | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 2.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Ian Foote, Mariusz Felisiak | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Simplified example to reproduce, with these models:
class State(models.Model): name = models.CharField(max_length=100) class Location(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'))
Note:
See TracTickets
for help on using tickets.