Skip to content

django52 fixes #24588

Merged
eviljeff merged 27 commits intomozilla:masterfrom
eviljeff:15585-django52
Mar 16, 2026
Merged

django52 fixes #24588
eviljeff merged 27 commits intomozilla:masterfrom
eviljeff:15585-django52

Conversation

@eviljeff
Copy link
Copy Markdown
Member

@eviljeff eviljeff commented Mar 11, 2026

Fixes: mozilla/addons#15585

Description

All the django52 fixes~, plus CI changes to run tests on both django52 and django42.~

Context

The complex pipeline we have from ci.yml, through: sub-test yml, actions, dockerfile, makefile, install_deps.py, -and in some cases back again- makes for a nightmarish environment for adding switching between django versions. (For the django42 and django32 upgrades it was considerably easier). Some of the passing down of django_version/DJANGO_VERSION may not actually be necessary.

It would be cleaner to not include any of this in the eventual merge, and to just directly upgrade in prod.txt, at the cost of losing the ability to switch backwards and forwards, and test both django versions in the same CI.
^ that's what we're doing, except without the upgrade in prod.txt - we're sticking on django4.2 in this pr

Testing

Test all the things!

  • to run locally with django52, DJANGO_VERSION=django52 make up
  • or DJANGO_VERSION=django52 make update_deps with docker already up.- quicker because it doesn't have to rebuild everything in the docker image, but less authentic.
  • double check it actually worked with /__version__ (or amo-info webextension)

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@eviljeff eviljeff force-pushed the 15585-django52 branch 5 times, most recently from 7362a2f to 926b079 Compare March 11, 2026 17:05
assert set(inputs) == set(data.items())

# Same for the 'search' form
form = doc('#changelist-filter form')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this part of the test never worked as expected - we were using the same selector as the previous chunk of code. I couldn't figure out what it was supposed to be testing exactly so I removed it.

target_versions = (
self.target_versions.no_transforms()
.only('pk', 'version')
.defer('approval_notes')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isn't really the same as the only it replaces, but I figured only approval_notes was potentially a huge chunk of text. But we could tighten it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that's fine

self.grant_permission(user, 'Admin:Advanced')
self.client.force_login(user)
with self.assertNumQueries(20):
with self.assertNumQueries(20 if self.is_django42 else 18):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From looking into one of the other tests, the savepoints got optimised - previoulsy in some of these cases there were 4 savepoint related queries; now 2 in django52

data_types = {
**mysql_base.DatabaseWrapper.data_types,
# in django52 the class property is _data_types instead.
# TODO: this overwrite's django52's special handling for mariadb! Make it work.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Once we drop django42 support we can rewrite this in a way that doesn't break mariadb. Seems a fair tradeoff (given it's only a problem if we want to switch away from mysql to mariadb) in the meantime.

if not self.has_listed:
# add empty label back
listed.empty_label = listed_empty_label
listed.choices = [('', listed_empty_label)]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

couldn't quite get to the bottom of what changed that made our current hack break, but switching it around so we add the empty label when there is no applicable listed version, rather than remove it when there is, seemed to fix it 🤷

# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'
USE_TZ = False
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

default changed in django52

USE_I18N = True

# This enables localized formatting of numbers and dates/times. Deprecated in Django4.1
USE_L10N = True
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

setting dropped in django52, and was already defaulted to True in django42

@eviljeff eviljeff marked this pull request as ready for review March 11, 2026 18:12
@eviljeff eviljeff changed the title WIP django52 fixes django52 fixes Mar 11, 2026
@eviljeff eviljeff requested a review from diox March 11, 2026 18:16
@diox
Copy link
Copy Markdown
Member

diox commented Mar 16, 2026

Given the changes, I'm not sure we should bother with the added CI complexity. Could we split this and run most of the changes in master with 4.2 now, and then upgrade in a different PR later ?

@eviljeff
Copy link
Copy Markdown
Member Author

(rebased to get the mysql upgrade, and added jslex replacement). Once CI passes on 4.2 and 5.2 I'll strip out the CI, etc, changes so it all applies to 4.2 only.

@eviljeff eviljeff requested a review from diox March 16, 2026 15:05
@eviljeff eviljeff merged commit 5f06b2d into mozilla:master Mar 16, 2026
43 checks passed
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.

[Task]: Upgrade to django 5.2 LTS

2 participants