Configuring throttling policies in the Django REST framework
Now, we will configure throttling policies for the class-based views related to drones: DroneList
and DroneDetail
. We will override the values for the following class attributes for the class-based views:
throttle_classes
: This class attribute specifies a tuple with the names of the classes that will manage throttling rules for the class. In this case, we will specify theScopedRateThrottle
class as the only member of the tuple.throttle_scope
: This class attribute specifies the throttle scope name that theScopedRateThrottle
class will use to accumulate the number of requests and limit the rate of requests.
This way, we will make these class-based views work with the ScopedRateThrottle
class and we will configure the throttle scope that this class will consider for each of the class based views related to drones.
Open the restful01/drones/views.py
file and add the following lines after the last line that declares the imports, before...