We will use a combination of the three throttling classes to achieve our previously explained goals. Make sure you quit the Django development server. Remember that you just need to press Ctrl + C in the Terminal or Command Prompt window in which it is running.
Open the settings.py
file in the games_service/games_service
folder. Add the following highlighted lines after the first line that declares the dictionary named REST_FRAMEWORK
to add the new 'DEFAULT_THROTTLE_CLASSES'
and 'DEFAULT_THROTTLE_RATES'
setting keys. Don't remove the lines that will appear after the new highlighted lines. We don't show them to avoid repeating code. The code file for the sample is included in the restful_python_2_08_02
folder, in the Django01/games-service/games_service/settings.py
file:
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': (
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle',
),
'DEFAULT_THROTTLE_RATES...