aboutsummaryrefslogtreecommitdiffstats
path: root/examples/permissionsexample/views.py
blob: 20e7cba7af4c151bc8158835a24778fe367d1c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from djangorestframework.views import View
from djangorestframework.permissions import PerUserThrottling


class ThrottlingExampleView(View):
    """
    A basic read-only View that has a **per-user throttle** of 10 requests per minute.
    
    If a user exceeds the 10 requests limit within a period of one minute, the
    throttle will be applied until 60 seconds have passed since the first request.
    """
    
    permissions = ( PerUserThrottling, )
    throttle = '10/min'
    
    def get(self, request):
        """
        Handle GET requests.
        """
        return "Successful response to GET request because throttle is not yet active."