Add Django 5.2 support and compatibility fixes#4646
Conversation
|
|
||
| USE_I18N = True | ||
|
|
||
| USE_L10N = True |
There was a problem hiding this comment.
We currently have USE_L10N = True in this repository. Since this setting is enabled by default in Django 4.2 and removed entirely in Django 5.2, it is safe to remove without causing any issues in production.
| """ | ||
|
|
||
| model = Person | ||
| queryset_pagination = settings.ELASTICSEARCH_DSL_QUERYSET_PAGINATION |
There was a problem hiding this comment.
queryset_pagination was in Meta, which is ignored by django-elasticsearch-dsl. Moved it to the Django class as per the documentation.
| course__degree_course_curricula=instance, | ||
| external_key__isnull=False | ||
| ).iterator() | ||
| ).iterator(chunk_size=settings.ITERATOR_CHUNK_SIZE) |
There was a problem hiding this comment.
In Django 5.0, QuerySet.iterator() requires an explicit chunk_size, especially when using prefetches. I set it to 2000 to match the previous default value used in earlier versions. Release Notes 5.0
| program_type = factories.ProgramTypeFactory(applicable_seat_types=[verified_seat_type]) | ||
| program_filter = ProgramEligibilityFilter(None, {self.parameter_name: 1}, None, None) | ||
| value = [1] if DJANGO_VERSION >= (5, 2) else 1 | ||
| program_filter = ProgramEligibilityFilter(None, {self.parameter_name: value}, None, None) |
There was a problem hiding this comment.
Django 5.0+ returns a tuple from SimpleListFilter.value(), even for single values.
Release note
This change in django 5.0 is for a bug fix discussed in the forums.
f93df2d to
a943b4c
Compare
875a44b to
16d23d8
Compare
| # than pumping them into the local vars. | ||
| dict_updates = {key: config_from_yaml.pop(key, None) for key in DICT_UPDATE_KEYS} | ||
|
|
||
| # Extract legacy storage backend settings from yaml config to avoid conflicts. |
There was a problem hiding this comment.
Need to verify this on sandbox or stage.
67fc0ae to
a10c65a
Compare
|
@feanil Please review. This is first of django52 compatibility. |
feanil
left a comment
There was a problem hiding this comment.
Changes generally make sense but I'm not sure why the tests aren't running.
|
Maybe do a rebase here since there is also a conflict that needs to be resolved? |
|
Thanks for the pull request, @mfarhan943! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
96067c4 to
41cf4c4
Compare
41cf4c4 to
ebafa9c
Compare
There was a problem hiding this comment.
Looks like the tests are failing in part because you're trying to upload coverage related artifacts with the same name twice. I think the correct thing to do is only publish coverage data from the latest version so, I think update the conditional for the coverage related tasks to only run on django-version == 'django52'.
ebafa9c to
f613861
Compare
|
@feanil Please review. |
|
@awais786 does this need the same kind of DEPR similar to openedx/openedx-platform#37333 for this repo for operators? |
Makefile
Outdated
| # Let tox control the Django version for tests | ||
| grep -e "^django==" requirements/local.txt > requirements/django.txt | ||
| sed -i.tmp '/^[dD]jango==/d' requirements/test.txt | ||
| sed -i.tmp '/^djangorestframework==/d' requirements/test.txt |
There was a problem hiding this comment.
Is this introducing a bug? It looks like the djangorestframework requirement is removed but not added back in via Tox to any other version. So we're no longer explicitly setting the version and likely getting whatever version is coming from other base requirements. I think we don't want that.
|
Yes, let me add for this and credentials also. |
565ab8c to
0f3be0e
Compare
|
Changes generally look good, please link the relevant DEPR here once we have it. Then I think this can probably be approved and merged. |
Done |
- Upgraded codebase to support Django 5.2 - Resolved attribute errors on StdImageFieldFile - Added setting ITERATOR_CHUNK_SIZE for Django 5.2 compatibility
0f3be0e to
a14d50e
Compare
|
@awais786 or @mfarhan943 can you make the followup PR that makes django 5.2 the default once this lands? |
|
@feanil we will fix STORAGES stuff PR first like we did in credentials. So we will make it today. After that we will make default PR for |
Description
Testing Instructions
git ls-files -z -- '*.py' | xargs -0r django-upgrade --target-version 5.2
python manage.py shell
Expected result:
Django shell will load without any error.
DEPR: #4668