From d0dca45d496b263a5acf692297b9b658214ca1ed Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 8 Oct 2015 20:59:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=20debug=20=E4=B8=8B=E5=85=B3=E9=97=AD?= =?UTF-8?q?=20rest=20framework=20=E7=9A=84=E8=B0=83=E8=AF=95=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oj/settings.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/oj/settings.py b/oj/settings.py index 7e47919..8231216 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -54,9 +54,14 @@ INSTALLED_APPS = ( 'django_extensions', 'rest_framework', - 'rest_framework_swagger', ) +if DEBUG: + INSTALLED_APPS += ( + 'debug_toolbar', + 'rest_framework_swagger', + ) + MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -159,10 +164,17 @@ LOGGING = { }, } - -REST_FRAMEWORK = { - 'TEST_REQUEST_DEFAULT_FORMAT': 'json' -} +if DEBUG: + REST_FRAMEWORK = { + 'TEST_REQUEST_DEFAULT_FORMAT': 'json' + } +else: + REST_FRAMEWORK = { + 'TEST_REQUEST_DEFAULT_FORMAT': 'json', + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) + } DATABASE_ROUTERS = ['oj.db_router.DBRouter']