Building RESTful Python Web Services
上QQ阅读APP看书,第一时间看更新

Chapter 2.  Working with Class-Based Views and Hyperlinked APIs in Django

In this chapter, we will expand the capabilities of the RESTful API that we started in the previous chapter. We will change the ORM settings to work with a more powerful PostgreSQL database and we will take advantage of the advanced features included in Django REST Framework that allow us to reduce the boilerplate code for complex APIs, such as class-based views. We will:

  • Use model serializers to eliminate duplicate code
  • Work with wrappers to write API views
  • Use the default parsing and rendering options and move beyond JSON
  • Browse the API
  • Design a RESTful API to interact with a complex PostgreSQL database
  • Understand the tasks performed by each HTTP method
  • Declare relationships with the models
  • Manage serialization and deserialization with relationships and hyperlinks
  • Create class based views and use generic classes
  • Work with endpoints for the API
  • Create and retrieve related resources