3

I am writing an HTML5 frontend mobile app and thinking of creating RESTful APIs for getting data from server. For backend I am using Django, thus I was going thru various options available in Django for RESTful APIs, I came across tastypie, piston etc.

I got some of advantages of using these frameworks (like security etc) but I am still unclear on disadvantages of using plain django view based RESTful APIs. I am thinking to POST JSON object to plain django view, parse and process it and store it in Data base.

Similarly send GET request to django view, load data from various DB tables and send JSON object back as response (as mimetype as application/json).

I was experimenting with above and so far it seems it will work.

I need to get PROs/CONs on using various frameworks vs simple django views for production system for RESTful APIs.

Rushik
  • 1,121
  • 1
  • 11
  • 34
  • I didn't see a specific question in your question, but there are lots of existing questions/answers on the pros and cons of the Django API frameworks. For example: https://stackoverflow.com/questions/8430579/django-restful-api-django-piston-vs-django-tastypie. Be sure to search before asking a question. ;) Good luck! – Erik Jul 29 '12 at 19:32

1 Answers1

0

Depending on how complex you application is and your style of structuring application, different frameworks (piston, tasypie) can provide patterns on how to manage your REST data and provide pre-defined functions and classes that access your models directly (and how to define logic around it). They also often provide ways to deal with authentication and different formats for data: json, xml, encoding etc. They also have predefined views for generating documentation.

All of this is something that you will have to manually provide in your views. If it's a simple AJAX, then I personally use view with json response, but for more elaborate API's I find frameworks more productive.

Jure C.
  • 3,013
  • 28
  • 33
  • Thanks, my requirement is pretty simple, but my JSON object might be little complex (array of objects and sub objects), anyway for JSON object parsing and sending back I will be using json package in python (dump and loads). Do you see any advantage on parsing/building json objects using various framework ? – Rushik Jul 29 '12 at 19:35
  • 1
    Not really. As far as I've seen, they all would use python package for json (or use the built-one) and call .dumps or .serialize on it. If you don't need the benefits that I listed and it is just a few views the framework might be an overkill for you. – Jure C. Jul 29 '12 at 19:40