Skip to content

Commit

Permalink
Fixed Django 5.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonb committed Aug 11, 2024
1 parent 222f5d9 commit 76a5357
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
django-version: ['4.2', '5.0', '5.1', 'main']
include:
- python-version: '3.8'
django-version: '4.2'
- python-version: '3.9'
django-version: '4.2'
exclude:
- python-version: '3.8'
django-version: '5.0'
- python-version: '3.8'
django-version: '5.1'
- python-version: '3.8'
django-version: 'main'
- python-version: '3.9'
django-version: '5.0'
- python-version: '3.9'
django-version: '5.1'
- python-version: '3.9'
django-version: 'main'

services:
postgres:
Expand Down
5 changes: 5 additions & 0 deletions sortedm2m/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def get_queryset(self):
queryset = super().get_queryset()
return self._apply_rel_ordering(queryset)

def get_prefetch_querysets(self, instances, queryset=None):
# Apply the same ordering for prefetch ones
result = super().get_prefetch_querysets(instances, queryset)
return (self._apply_rel_ordering(result[0]),) + result[1:]

def get_prefetch_queryset(self, instances, queryset=None):
# Apply the same ordering for prefetch ones
result = super().get_prefetch_queryset(instances, queryset)
Expand Down
2 changes: 1 addition & 1 deletion sortedm2m_tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def set_up_test_model(
# Make the "current" state.
model_options = {
"swappable": "TEST_SWAP_MODEL",
"index_together": [["weight", "pink"]] if index_together else [],
"indexes": models.Index(fields=["weight", "pink"]) if index_together else [],
"unique_together": [["pink", "weight"]] if unique_together else [],
}
if options:
Expand Down

0 comments on commit 76a5357

Please sign in to comment.