@@ -225,7 +225,7 @@ def get_attname(self):
225
225
def relationship_related_query_name (self ):
226
226
return self .remote_field .name
227
227
228
- def get_extra_restriction (self , alias , related_alias ):
228
+ def _get_extra_restriction (self , alias , related_alias ):
229
229
return Restriction (
230
230
forward = False ,
231
231
local_model = self .related_model ,
@@ -235,6 +235,18 @@ def get_extra_restriction(self, alias, related_alias):
235
235
predicate = self .field .predicate ,
236
236
)
237
237
238
+ def _get_extra_restriction_legacy (self , where_class , alias , related_alias ):
239
+ # this is a shim to maintain compatibility with django < 4.0
240
+ return self ._get_extra_restriction (alias , related_alias )
241
+
242
+ # this is required to handle a change in Django 4.0
243
+ # https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous
244
+ # the signature of the (private) funtion was changed
245
+ if django .VERSION < (4 , 0 ):
246
+ get_extra_restriction = _get_extra_restriction_legacy
247
+ else :
248
+ get_extra_restriction = _get_extra_restriction
249
+
238
250
@classmethod
239
251
def _resolve_expression_local_references (cls , expr , obj ):
240
252
if isinstance (expr , L ):
@@ -351,7 +363,7 @@ def field(self):
351
363
def get_accessor_name (self ):
352
364
return self .name
353
365
354
- def get_extra_restriction (self , related_alias , local_alias ):
366
+ def _get_extra_restriction (self , related_alias , local_alias ):
355
367
return Restriction (
356
368
forward = True ,
357
369
local_model = self .model ,
@@ -361,6 +373,19 @@ def get_extra_restriction(self, related_alias, local_alias):
361
373
predicate = self .predicate ,
362
374
)
363
375
376
+ def _get_extra_restriction_legacy (self , where_class , alias , related_alias ):
377
+ # this is a shim to maintain compatibility with django < 4.0
378
+ return self ._get_extra_restriction (alias , related_alias )
379
+
380
+ # this is required to handle a change in Django 4.0
381
+ # https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous
382
+ # the signature of the (private) funtion was changed
383
+ if django .VERSION < (4 , 0 ):
384
+ get_extra_restriction = _get_extra_restriction_legacy
385
+ else :
386
+ get_extra_restriction = _get_extra_restriction
387
+
388
+
364
389
def get_forward_related_filter (self , obj ):
365
390
"""
366
391
Return the filter arguments which select the instances of self.model
0 commit comments