Unable to override global AsyncThrottle with controller-level SyncThrottle
bug
### What's wrong?
Hi,
I may be misunderstanding how throttling is intended to work, so I wanted to ask whether this behavior is expected or if it might be a bug.
I have configured an `AsyncThrottle` in my global `DMR_SETTINGS`:
```python
DMR_SETTINGS = {
Settings.throttling: [
AsyncThrottle(...)
]
}
```
Then I created a synchronous controller and explicitly defined a `SyncThrottle` on the controller itself:
```python
class MyEndpoint(Controller):
throttling = [
SyncThrottle(...)
]
```
I expected the controller-level throttle to be used for this endpoint. However, DMR raises the following error:
```text
dmr.exceptions.EndpointMetadataError:
All throttling instances must be subtypes of
<class 'dmr.throttling.base.SyncThrottle'>
for self.endpoint_name='MyEndpoint.post'
```
From the error and my testing, it appears that the global throttles and controller throttles are being combined, rather than the controller throttles overriding the global ones. As a result, the endpoint ends up with both an `AsyncThrottle` and a `SyncThrottle`, which causes the validation error.
Is this the intended behavior? If so, what is the recommended way to define endpoint-specific throttling when global throttling is configured? Or is this a bug in the throttling resolution logic?
Thanks.
### How it should be?
I expected the controller-level `throttling` configuration to take precedence over the global throttling configuration for that endpoint.
If the intended behavior is to merge global and controller throttles, it would be helpful if this were documented and if there were a way to explicitly override global throttles when needed.
### Used versions
"django-modern-rest[msgspec,pydantic,jwt]>=0.10.0"
### OS information
Fedora Linux 6.17.12-300.fc43.x86_64
关闭于 2026-06-19 3 条评论