当前位置: 首页>>代码示例>>Python>>正文


Python TemplateResponse.status_code方法代码示例

本文整理汇总了Python中django.template.response.TemplateResponse.status_code方法的典型用法代码示例。如果您正苦于以下问题:Python TemplateResponse.status_code方法的具体用法?Python TemplateResponse.status_code怎么用?Python TemplateResponse.status_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.template.response.TemplateResponse的用法示例。


在下文中一共展示了TemplateResponse.status_code方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unauthed

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
    def unauthed(self, request):
        response = TemplateResponse(
            request=request,
            template='aldryn_sso/basicauth_auth_required.html',
            content_type='text/html',

        )
        response['WWW-Authenticate'] = 'Basic realm="Protected"'
        response.status_code = 401
        return response
开发者ID:aldryn,项目名称:aldryn-sso,代码行数:12,代码来源:middleware.py

示例2: challenge

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
    def challenge(self, request):
        realm = getattr(settings, 'API_AUTH_REALM', 'Restricted access')
        response = TemplateResponse(
            request,
            'api/401.html'
        )

        response['WWW-Authenticate'] = 'Basic realm="%s"' % realm
        response.status_code = 401
        return response
开发者ID:iamsteadman,项目名称:bambu-tools,代码行数:12,代码来源:http.py

示例3: _create_403_response

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
 def _create_403_response(self, request, operation, resource, authority=None, template_name=None, message=None):
     template_name = template_name or '403.html'
     response = TemplateResponse(request, template_name, {
         'operation': operation,
         'resource': resource,
         'authority': authority,
         'message': message,
         'status_code': '403'
     })
     response.status_code = 403
     return response
开发者ID:SolarisYan,项目名称:django-simple-rbac,代码行数:13,代码来源:middleware.py

示例4: post

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
    def post(self, request):

        if request.POST['ik_pm_no']:
            payment_id = request.POST['ik_pm_no']
            payment = Payment.objects.get(paymentid=payment_id)
            payment.status = request.POST['ik_inv_st']
            payment.system = request.POST['ik_pw_via']
            payment.amount = request.POST['ik_am']

            payment.save()
            self.sendmail(payment)
            response = TemplateResponse(
                request, self.get_template(payment), {'payment': payment, 'link': self.get_link(payment), })
            response.status_code = '200'
            return response
开发者ID:maremaremare,项目名称:biblio,代码行数:17,代码来源:views.py

示例5: confirmed

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
    def confirmed(request):
        comment = None
        if 'c' in request.GET:
            try:
                comment = get_model().objects.get(pk=request.GET['c'])
            except ObjectDoesNotExist:
                pass

        response = TemplateResponse(request, template, {
            'comment': comment,
            'is_ajax': is_ajax,
            'success' : True
        })
        response.status_code = comment.is_public and 201 or 202
        return response
开发者ID:rekcuFniarB,项目名称:django-mptt-comments,代码行数:17,代码来源:views.py

示例6: simple_browse

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
def simple_browse(request):
    response_code = None
    context = {}
    try:
        objs = _objects_by_type(REPO.SimpleCollection, SimpleCollection)
        objs = sorted(objs, key=lambda s: s.label)
        context['objs'] = objs
    except RequestFailed:
        response_code = 500
        # FIXME: this is duplicate logic from generic search view
        context['server_error'] = 'There was an error ' + \
            'contacting the digital repository. This ' + \
            'prevented us from completing your search. If ' + \
            'this problem persists, please alert the ' + \
            'repository administrator.'

    response = TemplateResponse(request, 'collection/simple_browse.html', context)
    if response_code is not None:
        response.status_code = response_code
    return response
开发者ID:emory-libraries,项目名称:TheKeep,代码行数:22,代码来源:views.py

示例7: handle_error

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
def handle_error(request):
    response = TemplateResponse(request, 'page/500.html', {})
    response.status_code = 500
    return response.render()
开发者ID:jccode2,项目名称:ella,代码行数:6,代码来源:views.py

示例8: page_not_found

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
def page_not_found(request):
    response = TemplateResponse(request, 'page/404.html', {})
    response.status_code = 404
    return response.render()
开发者ID:jccode2,项目名称:ella,代码行数:6,代码来源:views.py

示例9: _get_forbidden_rsponse

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
def _get_forbidden_rsponse(request):
    response = TemplateResponse(request, "403.html")
    response.status_code = HttpResponseForbidden.status_code
    return response
开发者ID:euangoddard,项目名称:eric,代码行数:6,代码来源:decorators.py

示例10: send_oauth_error

# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import status_code [as 别名]
		except OAuthError, ex:
			return send_oauth_error(ex)
		
		if request.method == 'GET':
			response = TemplateResponse(
				request,
				'api/auth/oauth/authorise.html',
				{
					'form': AuthoriseForm(),
					'app': app,
					'no_login_form': True,
					'popup': True
				}
			)
			
			response.status_code = 401
			response.realm = 'API'
			
			return response
		elif request.method == 'POST':
			callback = app.callback_url
			form = AuthoriseForm(data = request.POST)
			
			if request.user.is_authenticated():
				token = oauth_server.authorize_token(token, request.user)
				
				if callback:
					args = '?%s' % token.to_string(only_key = True)
					return HttpResponseRedirect(callback + args)
				else:
					return HttpResponse(token.to_string(only_key = True), mimetype = 'text/plain')
开发者ID:cheekybastard,项目名称:bambu-tools,代码行数:33,代码来源:oauth2.py


注:本文中的django.template.response.TemplateResponse.status_code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。