We enabled pagination to limit the size for the result sets. However, any client or user is able to specify a large number for the limit
value, such as 10000
, and generate a huge result set. In order to specify the maximum number that is accepted for the limit query parameter, it is necessary to create a customized version of the limit/offset pagination scheme that the Django REST framework provides us.
We made changes to the global configuration to use the rest_framework.pagination.LimitOffsetPagination
class to handle paginated responses. This class declares a max_limit
class attribute whose default value is equal to None
, which means there is no upper bound for the limit
value. We will indicate the upper bound value for the limit query parameter in the max_limit
class attribute.
Make sure you quit Django's development server. Remember that you just need to press Ctrl + C in the terminal or Command Prompt in which it is running.
Go to the restful01...