Hi All,

i am using django-tastypie to return django models as json object.

when i run the following code

var org = Backbone.Model.extend({

               urlRoot: 'api/orgnanization/',
        });


        var orgColl=Backbone.Collection.extend({
            model: org,
               urlRoot: 'api/orgnanization/',
               initialize:function(){
                   this.fetch();
                   console.log(this)
               }
        });

        var apiView=Backbone.View.extend({
            el:'.try',
            //template:,
            initialize:function(){
                this.listenTo(this.collection,'reset',this.render)
            },
            //events:{},
            render:function(){
                console.log(this.collection)
                //this.$el.html(this)
            },
        });

        var cos=new orgColl()
        new apiView({collection:cos})

i get the following in the chrome console
r {length: 0, models: Array[0], _byId: Object, constructor: function, model:
 function…}

   1. _byId: Object
   2. _events: Object
   3. _listenerId: "l7"
   4. length: 1
   5. meta: Object
   6. models: Array[1]
   7. __proto__: s


but when i look a the network the model is actually fetched from the 
database

   1. meta: {limit:20, next:null, offset:0, previous:null, total_count:3}
      1. limit: 20
      2. next: null
      3. offset: 0
      4. previous: null
      5. total_count: 3
   2. objects: [{id:1, name:eddmashinc, resource_uri:}, {id:2, name:trive, 
   resource_uri:},…]
      1. 0: {id:1, name:eddmashinc, resource_uri:}
         1. id: 1
         2. name: "eddmashinc"
         3. resource_uri: ""
      2. 1: {id:2, name:trive, resource_uri:}
         1. id: 2
         2. name: "trive"
         3. resource_uri: ""
      3. 2: {id:3, name:mashainc, resource_uri:}
         1. id: 3
         2. name: "mashainc"
         3. resource_uri: ""
         4. 
         
how do i get this data to display on the backbone view or what im i doing 
wrong ??


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f9c2e817-2595-4b4d-94f2-01db94e5f189%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to