我的Django中间件订单是否正确?

时间:2014-01-21 07:59:37

标签: django middleware

MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'django.middleware.http.ConditionalGetMiddleware',

'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',

'announce.middleware.AnnounceCookieMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'giaola.middleware.ForceDefaultLanguageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'mediagenerator.middleware.MediaMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
'minidetector.Middleware',
# Uncomment the next line for simple clickjacking protection:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'breadcrumbs.middleware.BreadcrumbsMiddleware',
'achievements.middleware.AutoAchievementChecker',
)

这些都是我的中间件,我不完全确定它们的顺序是正确的。

我怀疑GZip和HTMLmin是否位于顶部,其后跟着缓存,但中间件一直是我在Django中的弱点。

“ForceDefaultLanguageMiddleware”只是强制执行语言,如下所示:

def process_request(self, request):
    if request.META.has_key('HTTP_ACCEPT_LANGUAGE'):
        del request.META['HTTP_ACCEPT_LANGUAGE']

任何输入都会受到赞赏。

0 个答案:

没有答案