|
4 | 4 | import copy
|
5 | 5 | from collections import defaultdict
|
6 | 6 |
|
7 |
| -from django import get_version as get_django_version |
8 | 7 | from django.contrib.contenttypes.models import ContentType
|
9 | 8 | from django.core.exceptions import FieldDoesNotExist
|
10 | 9 | from django.db.models import FilteredRelation
|
@@ -157,35 +156,17 @@ def not_instance_of(self, *args):
|
157 | 156 | # Implementation in _translate_polymorphic_filter_defnition."""
|
158 | 157 | return self.filter(not_instance_of=args)
|
159 | 158 |
|
160 |
| - # Makes _filter_or_exclude compatible with the change in signature introduced in django at 9c9a3fe |
161 |
| - if get_django_version() >= "3.2": |
162 |
| - |
163 |
| - def _filter_or_exclude(self, negate, args, kwargs): |
164 |
| - # We override this internal Django function as it is used for all filter member functions. |
165 |
| - q_objects = translate_polymorphic_filter_definitions_in_args( |
166 |
| - queryset_model=self.model, args=args, using=self.db |
167 |
| - ) |
168 |
| - # filter_field='data' |
169 |
| - additional_args = translate_polymorphic_filter_definitions_in_kwargs( |
170 |
| - queryset_model=self.model, kwargs=kwargs, using=self.db |
171 |
| - ) |
172 |
| - args = list(q_objects) + additional_args |
173 |
| - return super()._filter_or_exclude(negate=negate, args=args, kwargs=kwargs) |
174 |
| - |
175 |
| - else: |
176 |
| - |
177 |
| - def _filter_or_exclude(self, negate, *args, **kwargs): |
178 |
| - # We override this internal Django function as it is used for all filter member functions. |
179 |
| - q_objects = translate_polymorphic_filter_definitions_in_args( |
180 |
| - self.model, args, using=self.db |
181 |
| - ) |
182 |
| - # filter_field='data' |
183 |
| - additional_args = translate_polymorphic_filter_definitions_in_kwargs( |
184 |
| - self.model, kwargs, using=self.db |
185 |
| - ) |
186 |
| - return super()._filter_or_exclude( |
187 |
| - negate, *(list(q_objects) + additional_args), **kwargs |
188 |
| - ) |
| 159 | + def _filter_or_exclude(self, negate, args, kwargs): |
| 160 | + # We override this internal Django function as it is used for all filter member functions. |
| 161 | + q_objects = translate_polymorphic_filter_definitions_in_args( |
| 162 | + queryset_model=self.model, args=args, using=self.db |
| 163 | + ) |
| 164 | + # filter_field='data' |
| 165 | + additional_args = translate_polymorphic_filter_definitions_in_kwargs( |
| 166 | + queryset_model=self.model, kwargs=kwargs, using=self.db |
| 167 | + ) |
| 168 | + args = list(q_objects) + additional_args |
| 169 | + return super()._filter_or_exclude(negate=negate, args=args, kwargs=kwargs) |
189 | 170 |
|
190 | 171 | def order_by(self, *field_names):
|
191 | 172 | """translate the field paths in the args, then call vanilla order_by."""
|
|
0 commit comments