' WSGIRequest'对象没有属性'模式'添加easy_thumbnails context_porcessors之后

时间:2015-08-17 13:34:49

标签: python django django-cms

我试图在settings.py中添加easy_thumbnails上下文处理器并得到下一个错误:

WSGIRequest'对象没有属性'模式'

上下文处理器配置:

TEMPLATES = [
    {
        ....
    'OPTIONS': {
    'context_processors': [
        ....
                'easy_thumbnails.processors.colorspace',
                'easy_thumbnails.processors.autocrop',
                'filer.thumbnail_processors.scale_and_crop_with_subject_location',
                'easy_thumbnails.processors.filters',
            ],
        },
    },
]

回溯:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:10801/uk/

Django Version: 1.8.3
Python Version: 3.4.0
Installed Applications:
('djangocms_admin_style',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'cms',
 'adminsortable2',
 'treebeard',
 'menus',
 'sekizai',
 'bootstrap3',
 'solo',
 'mptt',
 'modeltranslation',
 'easy_thumbnails',
 'filer',
 'meta',
 'meta_mixin',
 'djangocms_page_meta',
 'djangocms_inherit',
 'djangocms_picture',
 'djangocms_file',
 'djangocms_teaser',
 'djangocms_video',
 'djangocms_link',
 'djangocms_snippet',
 'djangocms_text_ckeditor',
 'catalog')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.language.LanguageCookieMiddleware')


Traceback:
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  164.                 response = response.render()
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/response.py" in render
  158.             self.content = self.rendered_content
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/response.py" in rendered_content
  135.         content = template.render(context, self._request)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/backends/django.py" in render
  74.         return self.template.render(context)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/base.py" in render
  208.                 with context.bind_template(self):
File "/usr/lib/python3.4/contextlib.py" in __enter__
  59.             return next(self.gen)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/context.py" in bind_template
  241.             updates.update(processor(self.request))
File "/home/catalog_cms/.env/lib/python3.4/site-packages/easy_thumbnails/processors.py" in colorspace
  64.     if im.mode == 'I':

Exception Type: AttributeError at /uk/
Exception Value: 'WSGIRequest' object has no attribute 'mode'

是的我使用最新版本的Pillow和easy_thumbnails。

1 个答案:

答案 0 :(得分:1)

我犯了一个错误,抱歉。这不是上下文处理器,而是缩略图处理器。我只想补充一下:

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'easy_thumbnails.processors.filters',       
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
)

现在一切正常。