本文整理汇总了Python中profiles.models.Profile.user_id方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.user_id方法的具体用法?Python Profile.user_id怎么用?Python Profile.user_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.user_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_complete
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user_id [as 别名]
def register_complete(request, id_booster, key):
user = authenticate(username=id_booster, password=key)
if not user:
raise Http404
if request.method == "POST":
form = ProfileCoreForm(request.POST)
if form.is_valid():
# User
user.first_name = form.cleaned_data["first_name"].lower().title()
user.last_name = form.cleaned_data["last_name"].upper()
user.set_password(form.cleaned_data["password"])
user.is_active = True
user.save()
# create corresponding profile
profile = Profile()
profile.user_id = user.id
profile.id_booster = user.username
profile.promotion = form.cleaned_data["promotion"]
profile.set_last_name(user.last_name)
profile.save()
# log & redirect
user_auth = authenticate(username=user.username, password=form.cleaned_data["password"])
login(request, user_auth)
return redirect("accounts-register-rules")
else:
form = ProfileCoreForm()
context = {"form": form, "pending_user": user}
return direct_to_template(request, "accounts/register_complete.html", extra_context=context)