本文整理汇总了Python中account.models.User.user方法的典型用法代码示例。如果您正苦于以下问题:Python User.user方法的具体用法?Python User.user怎么用?Python User.user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_account
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import user [as 别名]
def create_account(request):
c = {}
c.update(csrf(request))
is_signed_in = request.user.is_authenticated()
is_admin = request.user.is_superuser
matched = False
if request.method == 'POST':
match = models.User.objects.filter(username=request.POST['usr'])
if len(match) > 0:
matched = True
return render(request,'sign-up.html',{'signed_in': is_signed_in,'admin':is_admin, 'guest': not is_signed_in,'matched':matched})
else:
djuser = models.User.objects.create_user(username = request.POST['usr'],
email = request.POST['mail'],
password= request.POST['pass'],
)
djuser.first_name = request.POST['name'],
djuser.last_name = request.POST['lastname'],
user = User( address = request.POST['addr'],
phone_num = request.POST['tel'],
gender = request.POST['gender'],
avatar = None,
userType = 'Normal',
)
user.user = djuser
djuser.save()
user.save()
is_signed_in = request.user.is_authenticated()
is_admin = request.user.is_superuser
return redirect('/main/')
示例2: create_account
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import user [as 别名]
def create_account(request):
c = {}
c.update(csrf(request))
if request.method == 'POST':
djuser = models.User.objects.create_user(username = request.POST['usr'],
email = request.POST['mail'],
password= request.POST['pass'],
)
djuser.first_name = request.POST['name'],
djuser.last_name = request.POST['lastname'],
user = User( address = request.POST['addr'],
phone_num = request.POST['tel'],
gender = request.POST['gender'],
avatar = request.POST['file-4[]'],
userType = 'Normal',
)
user.user = djuser
djuser.save()
user.save()
return render(request,"main.html",{'signed_in':True})