本文整理汇总了Python中django.contrib.auth.forms.AuthenticationForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python AuthenticationForm.save方法的具体用法?Python AuthenticationForm.save怎么用?Python AuthenticationForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.forms.AuthenticationForm
的用法示例。
在下文中一共展示了AuthenticationForm.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: home
# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import save [as 别名]
def home(request):
"""This function renders the schools index.html"""
template = loader.get_template('schools/index.html')
context = RequestContext(request, {
})
if request.method == 'POST':
form = AuthenticationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/')
return HttpResponse(template.render(context))
示例2: send_oauth_error
# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import save [as 别名]
return send_oauth_error(
OAuthError('Invalid request parameters.')
)
try:
token = oauth_server.fetch_request_token(oauth_request)
if not token.consumer.user.is_superuser:
raise OAuthError('Method only allowed for approved applications.')
except OAuthError, err:
return send_oauth_error(err)
if request.method == 'POST':
form = RegistrationForm(data = request.POST)
if form.is_valid():
request.user = form.save()
token = oauth_server.authorize_token(token, request.user)
return HttpResponse(token.to_string())
return send_oauth_error(
OAuthError(
format_errors(form.errors)
)
)
return send_oauth_error(OAuthError('Invalid action.'))
@cache_page(60)
def post_thumbnail(request, stream, id, size = '560x560'):
post = get_object_or_404(
Post,