禁用 django 消息框架后出现问题
Issue after django messages framework disabled
我试图在 django 1.8 中禁用 django messages framework,所以我按照文档所说的做了:
If you don’t want to use messages, you can remove
'django.contrib.messages' from your INSTALLED_APPS, the
MessageMiddleware line from MIDDLEWARE_CLASSES, and the messages
context processor from 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
我认为 Django Admin 需要消息系统
我试图在 django 1.8 中禁用 django messages framework,所以我按照文档所说的做了:
If you don’t want to use messages, you can remove 'django.contrib.messages' from your INSTALLED_APPS, the MessageMiddleware line from MIDDLEWARE_CLASSES, and the messages context processor from 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
我认为 Django Admin 需要消息系统