Django URL and Backbone.js Router URL

I have a one-page backbone.js application configured using a router (well, actually, a Backbone.Marionette application with a Backbone.Marionette AppRouter, but nonetheless). However, the backend is based on Django, where I do not have a conf URL that directs to submissions for all the URLs that are already in the backbone.js routes.

Based on the existing URLs in the Django URL, Backbone.js will serve the backbone routes, regardless of what is specified in Django conf - it seems like something, something just has to be there.

Do I need to have the right Django views to offer a reserve for older browsers / SEO?

What are the best methods for coordinating a Django URL and a Backbone.js router?

+6
source share
2 answers

I found a post that solves this problem pretty well:

http://duganchen.ca/single-page-web-app-architecture-done-right/

In short, my arguments for including backups for non-javascript browsers and SEO reasons. During this post, non-javascript browsers make up ~ 1.4% (less than 2% of everything I read) of users, which makes SEO a prime consideration. Again, SEO may not be relevant to anyone reading this post, in which case it may be skipped.

I found the Thomas Davis tutorial using phantom.js quite useful. http://backbonetutorials.com/seo-for-single-page-apps/

However, another issue I needed to consider was the history API, which everyone but the latest IE browsers ignored. Given that my client clients, about 15% of which use IE <= 9, this was also a problem.

In the end, I also needed to use history.js . All in all, it was a lot of work to upgrade another very simple website. However, I learned a lot from this test.

+2
source

In my opinion, if your base application is really a single page, you don't need any django views. You can serve your index.html as a static file (during production, not even using django), and then let the base router take care of setting your URL as you do. You can use the basic history and go to fake URLs, add URL parameters, etc. For resources in your application.

+1
source

All Articles