I have set up a plain vanilla Django app (no backbone.js or other MVC framework) and integrated Tastypie.
Essentially, all the information I will require on every page is available from a single call to the API. Certain pages such as “mysite.com/cityA” would simply filter that information to only that of city A’s.
I am used to using backbone.js where a single collection can be shared by multiple views. How could I do this in plain Django? Would I do the call within an ‘index.html’ templates, from which I extend the other templates? I’m a little confused as to best practices.
Typically in Django, you would write a view, then render it and include URLs in the templates. Backbone can reuse all requested data, because it usually does not need to make a HTTP roundtrip when the user uses the application as a typical interaction with Django would work.
I would say that the default interaction models are different. If you have a database in the backend, you might want to resort to some kind of caching in your Django view – that would cut response times (but you’ll keep the HTTP roundtrip). You could use some client side cache (e.g. via localstorage), but still, the default Django model is to oscillate between the view and the rendered templates.