PermissionRequiredMixin
Verify that the current user has all specified permissions.
Attributes
| Attribute | Type | Description |
|---|---|---|
| permission_required | string or iterable = null | The permission or iterable of permissions that the user must possess to access the view. |
Methods
get_permission_required()
@classmethod
def get_permission_required() - > iterable
Override this method to override the permission_required attribute. Must return an iterable.
Returns
| Type | Description |
|---|---|
iterable | A collection of permission strings required to access the view. |
has_permission()
@classmethod
def has_permission() - > boolean
Override this method to customize the way permissions are checked.
Returns
| Type | Description |
|---|---|
boolean | True if the current user has all required permissions, False otherwise. |
dispatch()
@classmethod
def dispatch(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
*args: any,
**kwargs: any
) - > [HttpResponse](../../../http/response/httpresponse.md?sid=django_http_response_httpresponse)
Intercepts the request to verify user permissions before proceeding with standard request handling.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The incoming HTTP request object to be validated. |
| *args | any | Positional arguments passed to the view. |
| **kwargs | any | Keyword arguments passed to the view. |
Returns
| Type | Description |
|---|---|
[HttpResponse](../../../http/response/httpresponse.md?sid=django_http_response_httpresponse) | The standard HTTP response if authorized, or the result of handle_no_permission() if unauthorized. |