Search code examples
djangoweb-applicationsnode.jsbackbone.js

Using Node.js with Django and Backbone.js


Some background: I am planning to build an application with Django as the backend and using Backbone.js as the frontend Javascript framework. It is a Single page application (SPA) and this is the reason I decided to use Backbone.js. The application is similar to a blogging engine; users post entries containing text and images and are able to view them by "tag". They can search through their entries by "tag" or by a particular word.

Lately, after hearing about all the fuss about Node.js, I am wondering how it can help my application. But I don't want to make the app run purely on node.js on the backend, i.e., I still wish to use Django for the backend. Would it be possible to use Node for the "middle end" as mentioned here?

How can I optimize my app with Node.js?


Solution

  • It sounds like your application does not necessarily need Node.js. The main reasons you might want to use Node in addition to a more traditional framework like Django or Rails is if there is a real time or multiplayer aspect to your application.

    I wouldn't use Node.js because there is a lot of fuss about it - if you need the aforementioned functionality, though, it can be great.

    A high level architecture of your application might look something like:

    Django

    • Serving your single page
    • Serving assets(css, js, images, etc...)
    • Handling DB connection - best to setup RESTful routes for each data model
    • Data processing, etc...

    Backbone

    • Handling user interaction
    • Make http requests to read and write data

    Node (Optional)

    • Use something like Socket.io to notify clients of updates (instead of poling)
    • You can replace the functionality of Django with one or a combination of node modules