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


Python Account.created_by方法代码示例

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


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

示例1: register

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import created_by [as 别名]
def register(request):
    if request.method == "POST":
        nextPage = request.POST.get("next", "/")
        form = RegisterForm(request.POST)
        if form.is_valid():
            try:
                form.save()
            except:
                print "Unable to save form..."
                return render_to_response("registration/registration.html", {'form': form, 'next': nextPage}, context_instance=RequestContext(request))
            user = authenticate(username=request.POST.get("username"), password=request.POST.get("password1"))
            login(request, user)
            account = Account()
            account.user = User.objects.get(pk=user.id)
            account.created_by = user
            account.save()
            return redirect(nextPage)
        else:
            print "errors in registration"
            print form.errors
    else:
        form = RegisterForm()
        nextPage = request.GET.get("next", "/")
    # return render_to_response("registration/login.html", {}, context_instance=RequestContext(request))
    return redirect("ig.api.connectInstagram")
开发者ID:JasonTsao,项目名称:Fashion,代码行数:27,代码来源:views.py

示例2: create_account

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import created_by [as 别名]
def create_account(user):
    try:
        account = Account.objects.get(user=user)
        # print "Account already exists"
    except:
        account = Account()
        account.user = User.objects.get(pk=user.id)
        account.created_by = user
        try:
            account.save()
            return True
        except Exception as e:
            print "Unable to save account..."
            print e
            return False
    return True
开发者ID:JasonTsao,项目名称:Fashion,代码行数:18,代码来源:views.py


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