本文整理汇总了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")
示例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