本文整理匯總了Python中people.models.Person.user方法的典型用法代碼示例。如果您正苦於以下問題:Python Person.user方法的具體用法?Python Person.user怎麽用?Python Person.user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類people.models.Person
的用法示例。
在下文中一共展示了Person.user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create
# 需要導入模塊: from people.models import Person [as 別名]
# 或者: from people.models.Person import user [as 別名]
def create(request):
"""Render a form to create an entrepreneur."""
if request.method == "POST":
user_form = UserForm(request.POST)
startup_form = StartupForm(request.POST, request.FILES)
if user_form.is_valid() and startup_form.is_valid():
user = user_form.save()
startup = startup_form.save()
person = Person()
entrepreneur = Entrepreneur()
person.user = user
person.save()
entrepreneur.person = person
entrepreneur.startup = startup
entrepreneur.save()
msg = _("Your user and startup has been created successfully.")
return render_to_response("entrepreneurs/create.html",
{
"msg": msg,
"user": user,
},
context_instance=RequestContext(request)
)
else:
return render_to_response("entrepreneurs/create.html",
{
"user_form": user_form,
"startup_form": startup_form,
},
context_instance=RequestContext(request)
)
else:
return render_to_response("entrepreneurs/create.html",
{
"user_form": UserForm(),
"startup_form": StartupForm(),
},
context_instance=RequestContext(request)
)