我正在尝试禁用 django 1.8 中的django 消息框架,所以我做了文档所说的:
如果您不想使用消息,可以从 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