Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #10153: foreign key `gte` and `lte` lookups now work. Thanks, j…

…oelhooks and adurdin.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent bfdb7d2 commit fb9ac5729d309f6ec59e4089b7ab04378cb9082a @jacobian jacobian committed
2  django/db/models/fields/
@@ -155,7 +155,7 @@ def pk_trace(value):
# get_(next/prev)_by_date work; other lookups are not allowed since that
# gets messy pretty quick. This is a good candidate for some refactoring
# in the future.
- if lookup_type in ['exact', 'gt', 'lt']:
+ if lookup_type in ['exact', 'gt', 'lt', 'gte', 'lte']:
return [pk_trace(value)]
if lookup_type in ('range', 'in'):
return [pk_trace(v) for v in value]
16 tests/regressiontests/model_regress/
@@ -0,0 +1,16 @@
+from models import Worker
+from django.test import TestCase
+class RelatedModelOrderedLookupTest(TestCase):
+ """
+ Regression test for #10153: foreign key __gte and __lte lookups.
+ """
+ # The bug is that the following queries would raise:
+ # "TypeError: Related Field has invalid lookup: gte"
+ def test_related_gte_lookup(self):
+ Worker.objects.filter(department__gte=0)
+ def test_related_lte_lookup(self):
+ Worker.objects.filter(department__lte=0)

0 comments on commit fb9ac57

Please sign in to comment.
Something went wrong with that request. Please try again.