Summary

In this chapter, we defined the requirements for a complex RESTful Web Service in which we needed to work with drone categories, drones, pilots, and competitions. We created a new app with Django and configured the new web service.

We defined many-to-one relationships between the models with models.ForeignKey. We configured Django to work with a PostgreSQL database. We executed migrations that generated tables with relationships between them. We analyzed the generated database and we configured serialization and deserialization for the models. We declared two serializers for a single model to understand the flexibility we have with Django and the Django REST framework.

We defined hyperlinks with the help of the HyperlinkedModelSerializer class and we worked with class-based views. In this case, we took advantage of generic classes and generic views that generalize and mix predefined behaviors. We worked with routings and endpoints and we prepared our RESTful Web Service to work with the browsable API. We made many different HTTP requests to create and retrieve resources that have relationships between them. We did everything without writing a huge amount of code.

Now that we understand how to work with class-based views, and to take advantage of generalized behaviors and materialize complex relationships, we will add constraints, filtering, searching, ordering, and pagination features to our RESTful Web Service. We will cover these topics in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset