aboutsummaryrefslogtreecommitdiffstats
path: root/examples/permissionsexample/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/permissionsexample/views.py')
-rw-r--r--examples/permissionsexample/views.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/permissionsexample/views.py b/examples/permissionsexample/views.py
new file mode 100644
index 00000000..20e7cba7
--- /dev/null
+++ b/examples/permissionsexample/views.py
@@ -0,0 +1,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." \ No newline at end of file