Opened 6 years ago

Last modified 6 years ago

#29054 closed Bug

Unhashable type Point bug with multiple annotations — at Version 2

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 (last modified by Lachlan Cannon)

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 (2)

comment:1 by Lachlan Cannon, 6 years ago

Description: modified (diff)

comment:2 by Lachlan Cannon, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top