1👍
✅
Django already has a @permission_required decorator for this.
If the raise_exception parameter is given, the decorator will raise PermissionDenied, prompting the 403 (HTTP Forbidden) view instead of redirecting to the login page.
Source:stackexchange.com