If necessary, add the current locale or time zone to the cache key.
(request, cache_key)
| 337 | |
| 338 | |
| 339 | def _i18n_cache_key_suffix(request, cache_key): |
| 340 | """If necessary, add the current locale or time zone to the cache key.""" |
| 341 | if settings.USE_I18N: |
| 342 | # first check if LocaleMiddleware or another middleware added |
| 343 | # LANGUAGE_CODE to request, then fall back to the active language |
| 344 | # which in turn can also fall back to settings.LANGUAGE_CODE |
| 345 | cache_key += ".%s" % getattr(request, "LANGUAGE_CODE", get_language()) |
| 346 | if settings.USE_TZ: |
| 347 | cache_key += ".%s" % get_current_timezone_name() |
| 348 | return cache_key |
| 349 | |
| 350 | |
| 351 | def _generate_cache_key(request, method, headerlist, key_prefix): |
no test coverage detected