我猜我這是一個django錯誤,它通過ajax傳遞給瀏覽器控制檯。看一下django-dajaxice/dajaxice/core/Dajaxice.py
,Dajaxice在其頂部定義了自己的錯誤記錄器log = logging.getLogger('dajaxice')
。所以,你需要做的是去適應你的項目settings.py
,並與現有的處理程序例如爲:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
},
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'debug_console': {
'level': 'DEBUG',
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler'
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'dajaxice': {
'handlers': ['debug_console'],
'level': 'WARNING',
'propagate': False,
},
}
}
注意,這個例子需要的Django> = 1.5,因爲django.utils.log.RequireDebugTrue
的定義此記錄。
這當然不會解決你的問題,但至少你會得到真正的錯誤信息。 有關Django日誌記錄的詳細信息,請閱讀official docs。
真正的django錯誤來自@dajaxice_register
是一個方法裝飾器,它必須放在您想要在dajax中使用的每種方法的前面。將您的ajax.py
更改爲:
from django.utils import simplejson
from contacts.models import Notifications
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def args_example(request):
return simplejson.dumps({'message':'Message is '})
@dajaxice_register
def change(request):
return simplejson.dumps({'message':'Message is '})
感謝您的回覆! 我得到了控制檯的工作......但正確地說,我無法找出問題:( –
我更新了答案,以包括真正的錯誤消息的解決方案。 – frixx