本文整理汇总了Python中django.template.response.TemplateResponse.realm方法的典型用法代码示例。如果您正苦于以下问题:Python TemplateResponse.realm方法的具体用法?Python TemplateResponse.realm怎么用?Python TemplateResponse.realm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.template.response.TemplateResponse
的用法示例。
在下文中一共展示了TemplateResponse.realm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_oauth_error
# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import realm [as 别名]
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')
elif form.is_valid():
示例2: send_oauth_error
# 需要导入模块: from django.template.response import TemplateResponse [as 别名]
# 或者: from django.template.response.TemplateResponse import realm [as 别名]
app = oauth_server._get_consumer(oauth_request)
try:
token = oauth_server.fetch_request_token(oauth_request)
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")
elif form.is_valid():