Skip to content

Upgrade to Django 5.x #12104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 24, 2025
Merged

Upgrade to Django 5.x #12104

merged 18 commits into from
Apr 24, 2025

Conversation

humitos
Copy link
Member

@humitos humitos commented Apr 14, 2025

Upgrade our code base to Django 5.2

  • django-safemigrate had to be upgraded: you will find a lot of changes like Safe.before_deploy -> Safe.before_deploy() (all of them are in this particular commit: 4273e83)
  • I had to borrow django.core.files.storage.get_storage_class because it was deleted from Django 5.2
  • assertFormError tests were updated to match the new signature
  • django-celery-beat and django-storages were upgraded
  • Update some old migrations referring to indexes to make them work

Closes #12079
Closes #11505

humitos added 3 commits April 14, 2025 11:35
Initial steps to upgrade our codebase to Django 5.x
@humitos
Copy link
Member Author

humitos commented Apr 14, 2025

It seems we are blocked on django-celery-beat still #12079 (comment)

@humitos humitos added the Status: blocked Issue is blocked on another issue label Apr 14, 2025
@humitos humitos force-pushed the humitos/upgrade-django-5.2 branch from 039c85b to 4273e83 Compare April 16, 2025 09:05
@humitos humitos removed the Status: blocked Issue is blocked on another issue label Apr 16, 2025
@humitos humitos marked this pull request as ready for review April 16, 2025 10:28
@humitos humitos requested review from a team as code owners April 16, 2025 10:29
@humitos humitos requested a review from agjohnson April 16, 2025 10:29
@humitos humitos requested a review from stsewd April 16, 2025 10:29
@humitos
Copy link
Member Author

humitos commented Apr 16, 2025

All the tests are passing and the QA that I did locally worked fine.

I'm not sure why the CI checks is failing since I ran pre-commit locally and there is no modifications at all 🤷🏼

Comment on lines 13 to 21
# TODO: something changed in Django 5.2 that I need to comment this index together here.
# We need to research a little more.
#
# ValueError: Found wrong number (0) of constraints for builds_build(date, id)
#
# migrations.AlterIndexTogether(
# name="build",
# index_together={("date", "id"), ("version", "state", "type")},
# ),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to do something else with this, but I don't think so since these are old migrations.

Comment on lines 16 to 21
# TODO: something changed in Django 5.2 that I need to comment this index together here.
# We need to research a little more.
#
# ValueError: Found wrong number (0) of constraints for builds_build(date, id)
#
# ("date", "id"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. I had to delete this chunk of code to be able to run the tests. I don't think this will have any impact, tho.

@humitos
Copy link
Member Author

humitos commented Apr 16, 2025

I'm not sure why the CI checks is failing since I ran pre-commit locally and there is no modifications at all 🤷🏼

I reverted that file to what it was before to avoid this issue for now.

@humitos
Copy link
Member Author

humitos commented Apr 23, 2025

This is weird. Removing the migration file makes the migrations to work. However, checks complains about renaming an unnamed index.

Migrations for 'builds':
  readthedocs/builds/migrations/0062_rename_build_version_state_date_success_builds_buil_version_ee7034_idx_and_more.py
    ~ Rename unnamed index for ('version', 'state', 'date', 'success') on build to builds_buil_version_ee7034_idx
    ~ Rename unnamed index for ('version', 'state', 'type') on build to builds_buil_version_dd29f9_idx

@humitos
Copy link
Member Author

humitos commented Apr 23, 2025

I think I was able to make it work... Let see if all the tests pass now.

Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but we should definitely test more on .com, there we have a couple of deps that are not actively maintained, and may not be compatible with django 5.2..

@humitos
Copy link
Member Author

humitos commented Apr 24, 2025

I opened https://github.com/readthedocs/readthedocs-corporate/pull/1979 with the changes required. I'm going merge this one so we can start test it locally. Remember to rebuild the Docker images.

@humitos humitos merged commit 971d94a into main Apr 24, 2025
8 checks passed
@humitos humitos deleted the humitos/upgrade-django-5.2 branch April 24, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade application to Django 5.2
2 participants