Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What advantage of backbone js be using with django

My question is pretty simple: Currently the stack i use is django+coffeescript.

Is coupling django, backbone js a good idea? What advantage does it offer? Could anyone take me through the pros and cons.

PS: I know backbone js being an MVC.

like image 440
user993563 Avatar asked Jan 18 '23 01:01

user993563


2 Answers

Backbone.js offers an MVC way of doing things on the client-side. You can of course mix coffeescript with backbone quite easily.

If your app has to perform quite a lot of stuff on the client-side, adopting backbone is going to let you achieve this in a cleaner, more structured and elegant way.

like image 161
hymloth Avatar answered Jan 27 '23 21:01

hymloth


We use backbone+django extensively for an app, however, django alone doesn't really mix well with backbone, as most of the template system and some of the view system become superfluous when you communicate over a REST-api. Luckily you can easily add an API to django through piston, tastypie or our favorite django-rest-framework.

A problem is the doubled code-base, you need to define models and potentially form validation logic twice, in different frameworks. You might want to look at node.js as a replacement for django on the backend to be able to reuse logic on both sides of the http. Perhaps take a look at capsule from andyet.com (Henrik Joreteg to be precise) for reusing backbone logic across client and server.

A new kid on the block seems to be djangbone (https://github.com/af/djangbone) makes it really easy to use the Django ORM with backbone!

like image 23
Jens Alm Avatar answered Jan 27 '23 22:01

Jens Alm