Skip to content

Commit

Permalink
Remove workaround from select_subclasess()
Browse files Browse the repository at this point in the history
The workaround was for an issue that was fixed in Django 1.7: https://code.djangoproject.com/ticket/16855 / django/django@349c12d .
  • Loading branch information
adamchainz authored and hramezani committed Aug 17, 2022
1 parent 2dab8af commit d699745
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Unreleased
- Confirm support for `Django 4.0`
- Add Spanish translation
- Add French translation
- Drop Django 1.7 workaround from `select_subclasses()`

4.2.0 (2021-10-11)
------------------
Expand Down
6 changes: 0 additions & 6 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,10 @@ def select_subclasses(self, *subclasses):
)
subclasses = verified_subclasses

# workaround https://code.djangoproject.com/ticket/16855
previous_select_related = self.query.select_related
if subclasses:
new_qs = self.select_related(*subclasses)
else:
new_qs = self
previous_is_dict = isinstance(previous_select_related, dict)
new_is_dict = isinstance(new_qs.query.select_related, dict)
if previous_is_dict and new_is_dict:
new_qs.query.select_related.update(previous_select_related)
new_qs.subclasses = subclasses
return new_qs

Expand Down

0 comments on commit d699745

Please sign in to comment.