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


Python User.user方法代码示例

本文整理汇总了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/')
开发者ID:hvdharya,项目名称:SysRaVi,代码行数:32,代码来源:views.py

示例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})
开发者ID:farzin2000,项目名称:Ravi,代码行数:22,代码来源:views.py


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