Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add LocaleMiddleware to fix language chooser warning in tests#2877

Open
njg7194 wants to merge 1 commit intopython:main from
njg7194:fix/locale-middleware-warning
Open

Add LocaleMiddleware to fix language chooser warning in tests #2877
njg7194 wants to merge 1 commit intopython:main from
njg7194:fix/locale-middleware-warning

Conversation

@njg7194
Copy link

@njg7194 njg7194 commented Feb 1, 2026

Summary

This PR adds django.middleware.locale.LocaleMiddleware to the MIDDLEWARE setting to resolve the warning that appears during test runs.

Changes

  • Added LocaleMiddleware after SessionMiddleware in pydotorg/settings/base.py

Issue

Fixes #2742

Context

The admin_interface package's language chooser feature requires LocaleMiddleware to be present in the MIDDLEWARE setting. Without it, a warning is raised:

UserWarning: Language chooser requires 'django.middleware.locale.LocaleMiddleware' in your MIDDLEWARE to work.

The middleware is placed after SessionMiddleware as per Django's documentation, which recommends it be positioned early, but after SessionMiddleware.

This fixes the UserWarning about Language chooser requiring
'django.middleware.locale.LocaleMiddleware' in MIDDLEWARE.
Fixes python#2742 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JacobCoffee JacobCoffee Awaiting requested review from JacobCoffee JacobCoffee is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Tests: Language chooser middleware warning during tests

1 participant

AltStyle によって変換されたページ (->オリジナル) /