﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32358	Paginating a queryset with a distance lookup fails due to unhashable type Distance	Illia Volochii	nobody	"There is a model with a `location = models.PointField()` field.

Django 2.2.17 fails to paginate such a queryset because of `TypeError: unhashable type: 'Distance'`:
{{{
#!python
from django.contrib.gis.geos import Point
from django.contrib.gis.measure import Distance
from django.core.paginator import Paginator
from django.db.models import Case, IntegerField, Q, Value, When

point = Point(0, 0)
cities = City.objects.annotate(
    relative_distance=Case(
        When(Q(location__distance_lte=(point, Distance(mi=100))), then=Value(100)),
        default=Value(1000),
        output_field=IntegerField(),
    ),
)
Paginator(cities, 10).page(1)
}}}

This code works well with Django 1.11 and the latest development version.

For those who have faced this bug too, it is possible to use `Distance(mi=100).m` that is a hashable float in the lookup.

I attached a file with a full exception taceback.

Thanks,
Illia"	Bug	closed	GIS	dev	Normal	fixed	distance		Ready for checkin	1	0	0	0	1	0
