當前位置: 首頁>>代碼示例>>Python>>正文


Python defaults.permission_denied方法代碼示例

本文整理匯總了Python中django.views.defaults.permission_denied方法的典型用法代碼示例。如果您正苦於以下問題:Python defaults.permission_denied方法的具體用法?Python defaults.permission_denied怎麽用?Python defaults.permission_denied使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.views.defaults的用法示例。


在下文中一共展示了defaults.permission_denied方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: custom_permission_denied_view

# 需要導入模塊: from django.views import defaults [as 別名]
# 或者: from django.views.defaults import permission_denied [as 別名]
def custom_permission_denied_view(request, exception, template_name=ERROR_403_TEMPLATE_NAME):
    """
    The Permission Denied view normally lacks information about the view that triggered the
    exception, unless this information was provided in the exception object manually (as the
    second parameter).  This custom view attempts to include the relevant information if it
    is available.
    It is used, among others, by the Auth mixin to provide data about the offending view to
    the Debug toolbar.
    """
    response = permission_denied(request, exception.args[0] if exception.args else exception, template_name)
    try:
        response.context_data = getattr(response, 'context_data', {})
        response.context_data['view'] = exception.args[1]
    except IndexError:
        pass
    return response 
開發者ID:tejoesperanto,項目名稱:pasportaservo,代碼行數:18,代碼來源:views.py

示例2: debug_permission_denied

# 需要導入模塊: from django.views import defaults [as 別名]
# 或者: from django.views.defaults import permission_denied [as 別名]
def debug_permission_denied(request):
    return defaults.permission_denied(request, AttributeError('foobar')) 
開發者ID:edx,項目名稱:edx-analytics-dashboard,代碼行數:4,代碼來源:urls.py

示例3: forbidden

# 需要導入模塊: from django.views import defaults [as 別名]
# 或者: from django.views.defaults import permission_denied [as 別名]
def forbidden(request):
    """
    Custom 403 handler.
    """
    if request.path.startswith('/api/'):
        return HttpResponseForbidden('You do not have permission to access this resource',
                                     content_type='application/json')
    return defaults.permission_denied(request) 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:10,代碼來源:views.py


注:本文中的django.views.defaults.permission_denied方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。