mirror of
https://github.com/django/django.git
synced 2025-10-30 09:06:13 +00:00
Fixed #25972 -- Restored support for the isnull lookup with ForeignObject.
This commit is contained in:
@@ -25,7 +25,7 @@ from .related_descriptors import (
|
||||
)
|
||||
from .related_lookups import (
|
||||
RelatedExact, RelatedGreaterThan, RelatedGreaterThanOrEqual, RelatedIn,
|
||||
RelatedLessThan, RelatedLessThanOrEqual,
|
||||
RelatedIsNull, RelatedLessThan, RelatedLessThanOrEqual,
|
||||
)
|
||||
from .reverse_related import (
|
||||
ForeignObjectRel, ManyToManyRel, ManyToOneRel, OneToOneRel,
|
||||
@@ -672,9 +672,10 @@ class ForeignObject(RelatedField):
|
||||
return RelatedLessThan
|
||||
elif lookup_name == 'lte':
|
||||
return RelatedLessThanOrEqual
|
||||
elif lookup_name != 'isnull':
|
||||
elif lookup_name == 'isnull':
|
||||
return RelatedIsNull
|
||||
else:
|
||||
raise TypeError('Related Field got invalid lookup: %s' % lookup_name)
|
||||
return super(ForeignObject, self).get_lookup(lookup_name)
|
||||
|
||||
def get_transform(self, *args, **kwargs):
|
||||
raise NotImplementedError('Relational fields do not support transforms.')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.db.models.lookups import (
|
||||
Exact, GreaterThan, GreaterThanOrEqual, In, LessThan, LessThanOrEqual,
|
||||
Exact, GreaterThan, GreaterThanOrEqual, In, IsNull, LessThan,
|
||||
LessThanOrEqual,
|
||||
)
|
||||
|
||||
|
||||
@@ -131,3 +132,7 @@ class RelatedGreaterThanOrEqual(RelatedLookupMixin, GreaterThanOrEqual):
|
||||
|
||||
class RelatedLessThanOrEqual(RelatedLookupMixin, LessThanOrEqual):
|
||||
pass
|
||||
|
||||
|
||||
class RelatedIsNull(RelatedLookupMixin, IsNull):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user