禁用django消息框架后发出问题

时间:2015-08-06 21:58:58

标签: python django django-admin django-messages

我正在尝试禁用django 1.8中的django messages framework,所以我做了文档说的话:

  

如果您不想使用消息,可以删除   来自你的INSTALLED_APPS的'django.contrib.messages'   来自MIDDLEWARE_CLASSES的MessageMiddleware行和消息   来自TEMPLATES的上下文处理器。

所以我跟着这个,但是现在当我尝试通过管理员保存模型时,我得到以下错误:

MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware

这是我的追溯:

Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/core/scorehistory/5/

Django Version: 1.8.3
Python Version: 2.7.10
Installed Applications:
['grappelli',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'rest_framework',
 'apps.core']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware']


Traceback:
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  616.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  233.             return view(request, *args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
  1519.         return self.changeform_view(request, object_id, form_url, extra_context)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  34.             return bound_func(*args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  30.                 return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in inner
  145.                     return func(*args, **kwargs)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
  1475.                     return self.response_change(request, new_object)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in response_change
  1242.             self.message_user(request, msg, messages.SUCCESS)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in message_user
  1065.                 fail_silently=fail_silently)
File "/Users/yuriheupa/server/virtualenv/lib/python2.7/site-packages/django/contrib/messages/api.py" in add_message
  27.         raise MessageFailure('You cannot add messages without installing '

Exception Type: MessageFailure at /admin/core/scorehistory/5/
Exception Value: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware

1 个答案:

答案 0 :(得分:3)

我认为Django Admin需要消息系统