2012-08-04 88 views
0

我正在尝试在Django中使用Backbone。backbone-tastypie:超出最大调用堆栈大小

我第一次参加骨干的工作地方例如从todomvc: https://github.com/addyosmani/todomvc/tree/master/architecture-examples/backbone

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

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

不过,我得到一个的RangeError:最大调用堆栈大小超过时当我使用backbone-tastypie.js图层时,我在我的集​​合上使用了获取方法。

有什么想法?在错误

更多细节:

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 
+0

什么是你的代码是什么样子?可能有一个隐藏在某处的无限循环。 – 2012-08-04 16:42:44

+0

穆可能是对的。根据我对tastypie的(有限)经验,最大调用栈的大小超出了无限循环的结果 - 通常这会在你的tastypie代码中填充嵌入式资源。 – bento 2012-08-06 17:31:52

+0

对于迟到的回复,我再也无法访问互联网了。我实际上正在尝试调整todomvc的骨干示例以使用服务器而不是本地存储:https://github.com/addyosmani/todomvc/tree/master/architecture-examples/backbone – Michael 2012-08-15 20:26:52

回答

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 
     . 
     . 
     . 
相关问题