mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Split up doc sections more cleanly
This commit is contained in:
parent
b5daa40852
commit
cab4a2a5ad
|
@ -33,6 +33,10 @@ Might recieve an error response indicating that the `DELETE` method is not allow
|
||||||
|
|
||||||
{"detail": "Method 'DELETE' not allowed."}
|
{"detail": "Method 'DELETE' not allowed."}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# API Reference
|
||||||
|
|
||||||
## APIException
|
## APIException
|
||||||
|
|
||||||
**Signature:** `APIException(detail=None)`
|
**Signature:** `APIException(detail=None)`
|
||||||
|
|
|
@ -54,6 +54,8 @@ Or, if you're using the `@api_view` decorator with function based views.
|
||||||
}
|
}
|
||||||
return Response(content)
|
return Response(content)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# API Reference
|
# API Reference
|
||||||
|
|
||||||
## IsAuthenticated
|
## IsAuthenticated
|
||||||
|
@ -88,12 +90,15 @@ To use custom model permissions, override `DjangoModelPermissions` and set the `
|
||||||
|
|
||||||
The `DjangoModelPermissions` class also supports object-level permissions. Third-party authorization backends such as [django-guardian][guardian] that provide object-level permissions should work just fine with `DjangoModelPermissions` without any custom configuration required.
|
The `DjangoModelPermissions` class also supports object-level permissions. Third-party authorization backends such as [django-guardian][guardian] that provide object-level permissions should work just fine with `DjangoModelPermissions` without any custom configuration required.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# Custom permissions
|
# Custom permissions
|
||||||
|
|
||||||
To implement a custom permission, override `BasePermission` and implement the `.has_permission(self, request, view, obj=None)` method.
|
To implement a custom permission, override `BasePermission` and implement the `.has_permission(self, request, view, obj=None)` method.
|
||||||
|
|
||||||
The method should return `True` if the request should be granted access, and `False` otherwise.
|
The method should return `True` if the request should be granted access, and `False` otherwise.
|
||||||
|
|
||||||
|
|
||||||
[cite]: https://developer.apple.com/library/mac/#documentation/security/Conceptual/AuthenticationAndAuthorizationGuide/Authorization/Authorization.html
|
[cite]: https://developer.apple.com/library/mac/#documentation/security/Conceptual/AuthenticationAndAuthorizationGuide/Authorization/Authorization.html
|
||||||
[authentication]: authentication.md
|
[authentication]: authentication.md
|
||||||
[throttling]: throttling.md
|
[throttling]: throttling.md
|
||||||
|
|
|
@ -30,6 +30,10 @@ you should use the `api_settings` object. For example.
|
||||||
|
|
||||||
The `api_settings` object will check for any user-defined settings, and otherwise fallback to the default values. Any setting that uses string import paths to refer to a class will automatically import and return the referenced class, instead of the string literal.
|
The `api_settings` object will check for any user-defined settings, and otherwise fallback to the default values. Any setting that uses string import paths to refer to a class will automatically import and return the referenced class, instead of the string literal.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# API Reference
|
||||||
|
|
||||||
## DEFAULT_RENDERERS
|
## DEFAULT_RENDERERS
|
||||||
|
|
||||||
A list or tuple of renderer classes, that determines the default set of renderers that may be used when returning a `Response` object.
|
A list or tuple of renderer classes, that determines the default set of renderers that may be used when returning a `Response` object.
|
||||||
|
|
|
@ -63,6 +63,8 @@ Or, if you're using the `@api_view` decorator with function based views.
|
||||||
}
|
}
|
||||||
return Response(content)
|
return Response(content)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# API Reference
|
# API Reference
|
||||||
|
|
||||||
## AnonRateThrottle
|
## AnonRateThrottle
|
||||||
|
@ -144,6 +146,8 @@ For example, given the following views...
|
||||||
|
|
||||||
User requests to either `ContactListView` or `ContactDetailView` would be restricted to a total of 1000 requests per-day. User requests to `UploadView` would be restricted to 20 requests per day.
|
User requests to either `ContactListView` or `ContactDetailView` would be restricted to a total of 1000 requests per-day. User requests to `UploadView` would be restricted to 20 requests per day.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# Custom throttles
|
# Custom throttles
|
||||||
|
|
||||||
To create a custom throttle, override `BaseThrottle` and implement `.allow_request(request, view)`. The method should return `True` if the request should be allowed, and `False` otherwise.
|
To create a custom throttle, override `BaseThrottle` and implement `.allow_request(request, view)`. The method should return `True` if the request should be allowed, and `False` otherwise.
|
||||||
|
|
|
@ -33,8 +33,8 @@ For example:
|
||||||
"""
|
"""
|
||||||
Return a list of all users.
|
Return a list of all users.
|
||||||
"""
|
"""
|
||||||
users = [user.username for user in User.objects.all()]
|
usernames = [user.username for user in User.objects.all()]
|
||||||
return Response(users)
|
return Response(usernames)
|
||||||
|
|
||||||
## API policy attributes
|
## API policy attributes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user