#34030: add SystemCheckError for LocaleMiddleware
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: Jay Patel
Type: New feature | Status: assigned
Component: Core (Management | Version: 4.0
commands) |
Severity: Normal | Resolution:
Keywords: i18n, SystemCheck | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Maxim Danilov):
Replying to [comment:2 Jay Patel]:
> Check for LocaleMiddleware to come after SessionMiddleware can be done
by `if not hasattr(request, "session")` in `def process_request` of class
LocalMiddleware but how to check that it should come before
CommonMiddleware?
Hi, Jay. On my talk on django con i use this trick:
{{{
# settings.py
if USE_I18N:
MIDDLEWARE.insert(
next((idx for idx, _mw in enumerate(MIDDLEWARE, 1) if
_mw.endswith('SessionMiddleware')), 0),
'django.middleware.locale.LocaleMiddleware'
)
}}}
i check settings USE_I18N, and only after that i start to do something
with SessionMiddleware. I add LocaleMiddleware directly after
SessionMiddleware
otherwise it should be exception, but i skip it.
probably you can use it to check idx_of_SessionMiddleware <
idx_of_LocaleMiddleware < idx_of_commonMiddlevare.
It is don't matter, where to check, to check settings you don't need the
request.
--
Ticket URL: <https://code.djangoproject.com/ticket/34030#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018371ac4bdf-0367e480-fdda-4670-a02a-c263b8c6d986-000000%40eu-central-1.amazonses.com.