summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/contrib/gis/db/models/fields.py2
-rw-r--r--docs/releases/2.0.1.txt2
-rw-r--r--tests/gis_tests/geoapp/tests.py3
3 files changed, 7 insertions, 0 deletions
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index 5e869a8243..12af07b9b7 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -167,6 +167,8 @@ class BaseSpatialField(Field):
def get_prep_value(self, value):
obj = super().get_prep_value(value)
+ if obj is None:
+ return None
# When the input is not a geometry or raster, attempt to construct one
# from the given string input.
if isinstance(obj, GEOSGeometry):
diff --git a/docs/releases/2.0.1.txt b/docs/releases/2.0.1.txt
index 9c111a1674..25ba39cffe 100644
--- a/docs/releases/2.0.1.txt
+++ b/docs/releases/2.0.1.txt
@@ -21,3 +21,5 @@ Bugfixes
* Fixed a regression in caching of a ``GenericForeignKey`` when the referenced
model instance uses more than one level of multi-table inheritance
(:ticket:`28856`).
+
+* Reallowed filtering a queryset with ``GeometryField=None`` (:ticket:`28896`).
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index b5f4078981..cfc6829fff 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -385,6 +385,9 @@ class GeoLookupTest(TestCase):
# Puerto Rico should be NULL (it's a commonwealth unincorporated territory)
self.assertEqual(1, len(nullqs))
self.assertEqual('Puerto Rico', nullqs[0].name)
+ # GeometryField=None is an alias for __isnull=True.
+ self.assertCountEqual(State.objects.filter(poly=None), nullqs)
+ self.assertCountEqual(State.objects.exclude(poly=None), validqs)
# The valid states should be Colorado & Kansas
self.assertEqual(2, len(validqs))