0

我正在尝试将 Backbone 与 Django 一起使用。

我首先从 todomvc 中获取了 Backbone 的本地工作示例: https ://github.com/addyosmani/todomvc/tree/master/architecture-examples/backbone

然后我想使用服务器而不是本地存储。所以我为 REST API 选择了 django-tastypie。我在浏览器中使用 REST 客户端(邮递员)测试了 REST API,它可以正常工作。

然后我想让它与 todomvc 示例一起使用。我设置了一些东西来使用服务器而不是本地存储。我得到了大家推荐的小型转换层主干-tastypie.js。(https://github.com/PaulUithol/backbone-tastypie/blob/master/backbone_tastypie/static/js/backbone-tastypie.js)

但是,当我使用主干-tastypie.js 层时,当我在我的集​​合上使用 fetch 方法时,我得到RangeError: Maximum call stack size exceeded 。

任何想法?

有关错误的更多详细信息:

a = window.App
a.Todos.fetch()
RangeError: Maximum call stack size exceeded
arguments: Array[0]
length: 0
__proto__: Array[0]
concat: function concat() { [native code] }
constructor: function Array() { [native code] }
every: function every() { [native code] }
filter: function filter() { [native code] }
forEach: function forEach() { [native code] }
indexOf: function indexOf() { [native code] }
join: function join() { [native code] }
lastIndexOf: function lastIndexOf() { [native code] }
length: 0
map: function map() { [native code] }
pop: function pop() { [native code] }
push: function push() { [native code] }
reduce: function reduce() { [native code] }
reduceRight: function reduceRight() { [native code] }
reverse: function reverse() { [native code] }
shift: function shift() { [native code] }
slice: function slice() { [native code] }
some: function some() { [native code] }
sort: function sort() { [native code] }
splice: function splice() { [native code] }
toLocaleString: function toLocaleString() { [native code] }
toString: function toString() { [native code] }
unshift: function unshift() { [native code] }
__proto__: Object
get message: function () { [native code] }
arguments: null
caller: null
length: 0
name: ""
prototype: Object
__proto__: function Empty() {}
set message: function () { [native code] }
arguments: null
caller: null
length: 1
name: ""
prototype: Object
__proto__: function Empty() {}
stack: undefined
type: "stack_overflow"
__proto__: Error
arguments: undefined
constructor: function RangeError() { [native code] }
name: "RangeError"
stack: undefined
type: undefined
__proto__: SetUpError.d
4

1 回答 1

0

在您的资源中,您是否有类似的内容:

class MyResource1(ModelResource):
    attr1 = fields.ForeignKey('app.api.MyResource2', 'attr1', full=True)

    class Meta:
        queryset = bla bla
        .
        .
        .

 class MyResource2(ModelResource):
       attr2 = fields.ForeignKey('app.api.MyResource1', 'attr2', full=True)

    class Meta:
        queryset = bla bla
        .
        .
        .
于 2012-08-25T08:12:31.860 回答