Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 找不到记录器的处理程序;dajaxice“;_Python_Ajax_Django - Fatal编程技术网

Python 找不到记录器的处理程序;dajaxice“;

Python 找不到记录器的处理程序;dajaxice“;,python,ajax,django,Python,Ajax,Django,AoA, 我试图进行ajax调用,当我使用函数args_示例时,它成功发布,我得到响应“messageis”。。。但如果我调用函数change(与args_示例相同),我会在控制台中得到一个错误(找不到记录器dajaxice的处理程序) //ajax.py from django.utils import simplejson from contacts.models import Notifications from dajaxice.decorators import da

AoA, 我试图进行ajax调用,当我使用函数args_示例时,它成功发布,我得到响应“messageis”。。。但如果我调用函数change(与args_示例相同),我会在控制台中得到一个错误(找不到记录器dajaxice的处理程序)

//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 '})

def change(request):
    return simplejson.dumps({'message':'Message is '})
//Javascript

function in template
 setInterval(function(){

      Dajaxice.contacts.change(callback);

  },2000);

我猜这是一个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日志记录的详细信息,请阅读

真正的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 '})

谢谢你的回复!我让控制台工作了……但我正确地说,我无法解决问题:(我更新了答案,以包含真正错误消息的解决方案。