I am used to defining my django views with http request that send http response back with a python dictionary of data that i can iterate over and display. I am attempting to replace this with the use of backbone.js.
Currently i have a set up like so:
<ul id="teaching_students">
{% for student in students.object_list %}
<li class="selected">
<span> {{ student.name }} </span>
</li>
{% endfor %}
</ul>
and i would like to use ICanHaz.js and Mustache.js as javascript templates to fill {{ student.name}}
on the client side.
Using tastypie so far, i have a PersonResource
which has all the students coming back as json objects when the following url is passed.
http://127.0.0.1:8000/api/people/?format=json
- Do i need to generate an API view for this url in views.py, if so what does that look like?
- How do i call, in backbone.js, this url and set up a collection, view and a correct route ?
My client side structure is broken down into views/models
(i use require.js to bring them together).
I am using several plugins to help bridge the gap between backbone and tastypie (backbone-tastypie.js) but i really want to see how others have replaced traditional django template rendering with REST api's and backbone.js
EDIT: Adding Backbone model, here is the model i am using
define([
'underscore',
'backbone'
], function(_, Backbone) {
var PersonModel = Backbone.Model.extend({
defaults : {
},
initialize: function( options ) {
},
parse : function(res) {
// because of jsonp
return res.data;
}
});
return PersonModel;
});