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


Python Profile.firstname方法代码示例

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


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

示例1: register

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import firstname [as 别名]
def register(request):
	response = JSONResponse("success")
	if request.method != 'POST':
		response.add_error('Bad request.')
	else:
		print request.POST['birthday']
		valid = True
		match = User.objects.filter(username = request.POST['username'])
		if len(match) > 0:
			response.add_error('Username is already in use.', 'register_error')
			valid = False
		match = User.objects.filter(email = request.POST['email'])
		if len(match) > 0:
			response.add_error('Email address is already registered.', 'register_error')
			valid = False
		if len(request.POST['password']) < 6:
			response.add_error('The entered password is less than 6 characters.', 'register_error')
			valid = False
		if len(request.POST['username']) < 3:
			response.add_error('The requested username is too short.', 'register_error')
			valid = False
		if len(request.POST['firstname']) == 0 or len(request.POST['lastname']) == 0:
			response.add_error('You must provide both first and last name.', 'register_error')
		global mail_re
		if mail_re == None:
			mail_re = re.compile('^[a-zA-Z0-9._%-][email protected][a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$')
		if mail_re.match(request.POST['email']) is None:
			response.add_error('Invalid email address', 'register_error')
			valid = False
		if valid == True:
			user = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password'])
			user.save()
			profile = Profile()
			profile.userLink = user
			profile.birthday = datetime.datetime.strptime(request.POST['birthday'], '%Y-%m-%d').date()
			profile.firstname = request.POST['firstname']
			profile.lastname = request.POST['lastname']
			profile.country = request.POST['country']
			profile.biography = request.POST['bio']
			profile.rights = 0
			profile.save()
			user = authenticate(username=request.POST['username'], password=request.POST['password'])
			login(request, user)
	return response.respond()
开发者ID:Ezphares,项目名称:codename-Moving-Whales,代码行数:46,代码来源:views.py


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