What is the main advantage of using REST api instead of views in Django
is that ok to mixing in REST api and Views(REST api in one app and Views in another app) ?
Or do we need to write REST api for all apps? instead of mixing REST and Views
I am assuming you are asking about the advantages of a library like tastypie or django-rest-framework
I have never used tastypie, but for REST api's django-rest-framework provides a lot out of the box that makes development of these api's a lot quicker.
django-rest-framework provides things like:
From django-rest-framework site:
Some reasons you might want to use REST framework:
- The Web browseable API is a huge usability win for your developers.
- Authentication policies including OAuth1a and OAuth2 out of the box.
- Serialization that supports both ORM and non-ORM data sources.
- Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
- Extensive documentation, and great community support.
Ultimately, the main advantage, is that django-rest-api contains many tools to make it easier and faster to create rest apis. Everything that django-rest-api does you could implement yourself.
It is definitely ok to mix the two. Often times one django project will have an app that serves html content and another app that exposes the data through an API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With