Building RESTful Python Web Services Chapter 2
Chapter 2: Working with Class-based Views and Hyperlinked API's in Django
Use Model Serializers to Eliminate Duplicate Code
This is a short section that implements a better serializer class from Chapter 1. My complain is much the same as always, there is too much "magic" here. I would have preferred a more robust explanation of why the author is doing what he is doing, rather than what he is trying to accomplish.Working With Wrappers to Write API Views
We are introduced to the new HTTP verb OPTIONS, which when sent to our API will reply with how to use the API. This can be very useful information for us in the future, especially when dealing with new API's with minimal documentation.We are also introduced to the @api_view decorator. Decorators in Django are very useful. They will allow us to do many things including allowing cross site scripting requests.
Using the default parsing and rendering options and move beyond JSON
This section expands on the @api_view decorator. It allows us to get several neat features:- The ability to accept JSON or XML data.
- The ability to specify which verbs we will accept with our api.
Browsing the API
The author shows us how we get an easy web page to browse through our API, with no coding involved. This is a very nice feature of Django. For further study follow this link Django Rest Framework DocumentationDesigning a RESTful API to interact with a complext PostgresSQL database
We begin to design more complex tables to make our API more robust. The author has chosen PostGres which is a very nice database system. There is some prerequisite database knowledge to really know what he is talking about.Understanding the tasks performed by each HTTP method
We are told about the PUT and PATCH methods.PUT allows us to replace a whole resource, while PATCH will allow us to update a resource.
A resource being a Python Object that corresponds to rows in the database.
Comments
Post a Comment