Skip to content

Upgrade back-end code from Django 4.2 to 5.2 LTS - #8052

Open
acwhite211 wants to merge 48 commits into
mainfrom
issue-8046
Open

Upgrade back-end code from Django 4.2 to 5.2 LTS#8052
acwhite211 wants to merge 48 commits into
mainfrom
issue-8046

Conversation

@acwhite211

@acwhite211 acwhite211 commented May 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #8046

Upgrade Django from 4.2 to LTS version 5.2.

https://docs.djangoproject.com/en/6.0/releases/5.2/

Changes:

  • removed USE_L10N (A localization setting, that is now defaulted to true)
  • added new migration to fix many-to-many fields (django-generated)
  • Migrated GET request to logout to a POST request to be in HTTP (and django) spec
    • changed the logOut user tool (in Header/userToolDefinitions) to point to a new front-end endpoint: /specify/command/logout to match the cache clearing endpoint
    • this new endpoint (defined in Router/Routes.tsx) renders the Logout component
    • the Logout component makes the POST request to the backend and returns a loading screen

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests

Testing instructions

Note for dev testers
If you are testing on your local instance, change

command: npx webpack -w --mode development --color

from --mode development to --mode production. This is because in development mode, webpack will duplicate web requests, which when sending the POST request, the first one is aborted by the second, which causes ajax to flash an error on-screen before refreshing to the login page. This does not happen in production mode, as far as I have seen.

  • Ensure strings are localized correctly
    • verify that labels are not raw schema labels, i.e. ensure schema config labels are respected.
    • Ensure that switching languages behaves correctly.
  • Log out from several locations
    • Ensure that no error dialogs flash on the screen
    • Logging back in takes you to the splash screen
  • General UI/UX testing
    • especially the workbench and attachments/attachment bulk upload

Summary by CodeRabbit

  • New Features

    • Added a dedicated logout flow with loading feedback and redirect handling.
    • Improved logout navigation from collection, agent, and user menus.
  • Bug Fixes

    • Updated relationship mappings and database migrations for more reliable data handling.
    • Improved compatibility with current Django and authentication tooling.
  • Refactor

    • Simplified URL routing across backend endpoints without changing their primary destinations.
    • Updated date/time and boolean field configuration for Django compatibility.

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Django platform upgrade

Layer / File(s) Summary
Runtime and test foundation
requirements.txt, requirements-testing.txt, specifyweb/settings/__init__.py
Django, authentication, JWT, and testing dependencies are upgraded. USE_TZ is disabled and USE_L10N is removed.
URL routing modernization
specifyweb/backend/*/urls.py, specifyweb/specify/urls.py, specifyweb/backend/context/testurls.py, specifyweb/urls.py
Regex routes are replaced with path() routes. Typed converters are used for task IDs, viewset levels, and property names.
Model field compatibility migration
specifyweb/specify/utils/case_insensitive_bool.py, specifyweb/specify/migrations/*
NullBooleanField now extends the local BooleanField. A migration updates many-to-many field metadata and subsequent migration dependencies.

Frontend logout flow

Layer / File(s) Summary
Logout route and component
specifyweb/frontend/js_src/lib/components/Router/Routes.tsx, specifyweb/frontend/js_src/lib/components/Logout/index.tsx
A lazy command/logout route loads Logout. The component posts to /accounts/logout/, displays loading state, handles errors, and redirects to login.
Logout entry points
specifyweb/frontend/js_src/lib/components/ChooseCollection/index.tsx, specifyweb/frontend/js_src/lib/components/Core/Main.tsx, specifyweb/frontend/js_src/lib/components/Header/userToolDefinitions.ts
Logout links now target /specify/command/logout/. The collection action sends an explicit POST request.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Router
  participant Logout
  participant AccountsLogout
  participant LoginPage
  User->>Router: Open command/logout
  Router->>Logout: Lazy-load Logout
  Logout->>AccountsLogout: POST /accounts/logout/
  AccountsLogout-->>Logout: Return response
  Logout->>LoginPage: Redirect with nextUrl
Loading

Possibly related PRs

Suggested reviewers: carolinedenis, emenslin

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Automatic Tests ⚠️ Warning The PR changes 20 paths, adds a logout component and migrations, but changes no test files; focused searches found no related tests, and the checklist leaves automated tests unchecked. Add automatic tests for the POST logout flow and redirect, route registration, and migration/settings behavior, or document why each changed behavior does not require coverage.
Testing Instructions ⚠️ Warning Instructions cover logout symptoms but omit explicit checks for the new migration, USE_TZ behavior, and numerous path() API routes; “several locations” and “General UI/UX testing” are vague. Add exact logout locations and expected POST, redirect, nextUrl, cache, and localization results. Add migration/relationship, timezone/date, and representative backend URL checks with steps.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The dependency, settings, migration, URL, field, and logout changes support the Django 5.2 upgrade objective in [#8046].
Out of Scope Changes check ✅ Passed The changes are related to Django 5.2 compatibility and the linked logout-flow requirements; no unrelated code changes are evident.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: upgrading the back-end code from Django 4.2 to Django 5.2 LTS.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch issue-8046
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8046

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@g1rly-c0d3r g1rly-c0d3r self-assigned this Jul 14, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-111

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=804

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=OK
DJANGO_VERSION=5.2
DJANGO_CYCLE=5.2
EOL_DATE=2028-04-30
DAYS_REMAINING=620

--- Django ---
Version: 5.2
EOL: 2028-04-30
Status: OK


Triggered by ffecf67 on branch refs/heads/issue-8046
Comment thread specifyweb/backend/inheritance/urls.py Fixed
@g1rly-c0d3r
g1rly-c0d3r requested review from a team and rijulpoudel and removed request for emenslin August 13, 2026 15:09

@rijulpoudel rijulpoudel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Ensure strings are localized correctly
    • verify that labels are not raw schema labels, i.e. ensure schema config labels are respected.
    • Ensure that switching languages behaves correctly.
  • Log out from several locations
    • Ensure that no error dialogs flash on the screen
    • Logging back in takes you to the splash screen
  • General UI/UX testing
    • especially the workbench and attachments/attachment bulk upload

All tests pass like before and no error message on the Attachment Panel this time. I did not encounter any crashes, utcoffset errors, flashing error dialogs, or other UI regressions. Excellent job Eos!
Image

@CarolineDenis
CarolineDenis self-requested a review August 14, 2026 10:59
@CarolineDenis

Copy link
Copy Markdown
Contributor

@g1rly-c0d3r

@g1rly-c0d3r

Copy link
Copy Markdown
Contributor

While I was fixing the tests, I found two other issues that would be worth pursuing, one of which already existed: #641, and #8432.

@g1rly-c0d3r
g1rly-c0d3r requested review from rijulpoudel and removed request for a team and rijulpoudel August 19, 2026 19:20
@CarolineDenis
CarolineDenis requested review from a team, kwhuber and rijulpoudel August 21, 2026 11:43

@rijulpoudel rijulpoudel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Ensure strings are localized correctly
    • verify that labels are not raw schema labels, i.e. ensure schema config labels are respected.
    • Ensure that switching languages behaves correctly.
  • Log out from several locations
    • Ensure that no error dialogs flash on the screen
    • Logging back in takes you to the splash screen
  • General UI/UX testing
    • especially the workbench and attachments/attachment bulk upload

All the tests passed like the last time. All labels were oka, I was able to log out from everywhere and attachments/workbench didn't give any issues. Excellent work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Upgrade Django to LTS version 5.2

7 participants