# 01.频次限制
[toc]{type: "ol", level: [2, 3, 4, 5]}
### 全局配置
```python
### settings.dev
# 默认的频次限制类 可在局部配置
'DEFAULT_THROTTLE_CLASSES': [
# 匿名限制
'rest_framework.throttling.AnonRateThrottle',
# 用户限制
'rest_framework.throttling.UserRateThrottle',
],
# 默认的频次限制属性 可自定义频次
'DEFAULT_THROTTLE_RATES': {
'user': '12/minutes',
'anon': '3/minutes',
},
```
### 自定义配置
```python
### user.throttle
from rest_framework import throttling
class MyAnon(throttling.AnonRateThrottle):
THROTTLE_RATES = {
'anon': '10/day',
}
class MyUser(throttling.UserRateThrottle):
THROTTLE_RATES = {
'user': '10/minutes'
}
```