Javascript Django视图在浏览器中运行良好,通过主干获取时返回500

Javascript Django视图在浏览器中运行良好,通过主干获取时返回500,javascript,python,django,backbone.js,Javascript,Python,Django,Backbone.js,我有一个Django视图,它返回JSON格式的设置配置文件。当我在浏览器中获取它时,它工作正常。但当我尝试获取链接到它的主干集合时,它返回一个500,并显示以下错误消息:“'list'对象没有'find'属性” 堆栈跟踪: /usr/lib/python2.7/ConfigParser.py in _interpolate_some _interpvar_re = re.compile(r"%\(([^)]+)\)s") def _interpolate_some(self, o

我有一个Django视图,它返回JSON格式的设置配置文件。当我在浏览器中获取它时,它工作正常。但当我尝试获取链接到它的主干集合时,它返回一个500,并显示以下错误消息:“'list'对象没有'find'属性”

堆栈跟踪:

/usr/lib/python2.7/ConfigParser.py in _interpolate_some
    _interpvar_re = re.compile(r"%\(([^)]+)\)s")
    def _interpolate_some(self, option, accum, rest, section, map, depth):
        if depth > MAX_INTERPOLATION_DEPTH:
            raise InterpolationDepthError(option, section, rest)
        while rest:
            p = rest.find("%")  <-- where the stacktrace leads to
            if p < 0:
                accum.append(rest)
                return
            if p > 0:
                accum.append(rest[:p])
                rest = rest[p:]
Django视图代码:

def all_settings(request):
    settings_list = seiscomp_settings.get_all_settings()
    settings_array = []

    for name, value in settings_list:
        settings_obj = {}
        settings_obj['name'] = name
        settings_obj['value'] = value
        settings_array.append(settings_obj)

    return JsonResponse(settings_array, safe=False)
我不确定主干代码是否会有很大的帮助,但这里就是它

'use strict';

Shakescreen.module('Settings', function(Settings, App, Backbone) {
    Settings.Setting = Backbone.Model.extend({
        urlRoot: 'http://localhost:8000/settings',
        idAttribute: 'name',

        initialize: function() {
            console.log('creating setting object');
        }
    });

    Settings.SettingsCollection = Backbone.Collection.extend({
        url: 'http://localhost:8000/settings',
        model: Settings.Setting,

        initialize: function() {
            console.log('initialize empy settings collection');
        }
    });
});

因此SettingsCollection上的fetch返回一个500,但是通过浏览器的getthrough工作得很好(wget也是如此)。有什么提示吗?

由于请求中的
内容类型不同,代码是否采用了不同的路径?Stacktrace显示它来自同一视图。我认为这可能与CORS有关,但其他请求都能顺利通过。如果是CORS拒绝,浏览器不会接受响应,但服务器仍会发送响应。我建议安装并创建一个远程调试实例:
importrpdb2;rpdb2.start_embedded_调试器('foo')
。然后,在WinPDB中,当您发送失败的请求时,您可以远程连接到服务器。当我有多余的时间时,我必须尝试一下,谢谢。目前,我已将SafeConfigParser切换为旧的ConfigParser。这不是问题的答案,也不是理想的解决方案,但它确实有效。
'use strict';

Shakescreen.module('Settings', function(Settings, App, Backbone) {
    Settings.Setting = Backbone.Model.extend({
        urlRoot: 'http://localhost:8000/settings',
        idAttribute: 'name',

        initialize: function() {
            console.log('creating setting object');
        }
    });

    Settings.SettingsCollection = Backbone.Collection.extend({
        url: 'http://localhost:8000/settings',
        model: Settings.Setting,

        initialize: function() {
            console.log('initialize empy settings collection');
        }
    });
});