1
0
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:
Tomo Otsuka
2015-12-22 23:22:54 +00:00
committed by Tim Graham
parent 91cd4d8e8c
commit 8b6974a685
5 changed files with 32 additions and 10 deletions

View File

@@ -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.')

View File

@@ -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