Using Pagination, Django Signals, and Custom Middleware
In Chapter 6, we learned how to integrate Redis into the Django project and utilize Redis as a caching layer. Caching is important to get performance gains, but at times, we would want to optimize the overall response sent to the client. This can be achieved by implementing pagination.
In this chapter, we will learn how to implement pagination in Django and Django Rest Framework (DRF). Along with that, we will focus on Django signals and how they help developers decouple logic between different apps. In Chapter 5, we saw how Django authentication and authorization support using Django middleware out of the box; now we will learn how to create custom middleware in Django.
We will cover these topics in this chapter:
- Paginating responses in Django and DRF
- Demystifying Django signals
- Working with Django middleware
- Creating custom middleware