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


Python Account.synched方法代码示例

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


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

示例1: account_registration

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import synched [as 别名]
def account_registration(request):
#	if request.user.is_authenticated():
#		return HttpResponseRedirect("/profile/")

	if request.method == "POST":
		form = RegistrationForm(request.POST)


		if form.is_valid():
			password = form.cleaned_data["password"]
			logger.info( "Password is %s" % password )

			username = form.cleaned_data["email"]

			if len(username)>30:
				username = username[:30]

			user,success = Account.create_user(
				email=form.cleaned_data["email"],
				username= username,
				password= password,
				generate_password=False
			)

			acc = Account(user=user)
			acc.email = form.cleaned_data["email"]
			acc.name = form.cleaned_data["name"]
			acc.synched = False
			acc.ip_address = get_client_ip(request)
			acc.save()

			request.session[session_account_id_key] = acc.id

			return HttpResponseRedirect("/profile/")
		else:

			response_data = {
				"success":False,
				"errors": [(k, v[0]) for k, v in form.errors.items()]
			}

			return HttpResponse(json.dumps(response_data),mimetype="application/json")
#			return render_to_response("register.html",{"form":form},context_instance=RequestContext(request))

	else:
		"""user not submit"""
		form = RegistrationForm
		context = {"form":form}
		return render_to_response("register.html",context,context_instance=RequestContext(request))
开发者ID:bcambel,项目名称:learn-django,代码行数:51,代码来源:views.py


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