當前位置: 首頁>>代碼示例>>Python>>正文


Python Person.user方法代碼示例

本文整理匯總了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)
        )
開發者ID:alvarohurtado84,項目名稱:mentoring_manager,代碼行數:51,代碼來源:views.py


注:本文中的people.models.Person.user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。