本文整理汇总了Python中models.Branch.create_main_branch方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.create_main_branch方法的具体用法?Python Branch.create_main_branch怎么用?Python Branch.create_main_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Branch
的用法示例。
在下文中一共展示了Branch.create_main_branch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_create
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import create_main_branch [as 别名]
def update_create(request, id=0):
if request.method not in ['GET', 'POST']:
return HttpResponseNotAllowed(permitted_methods=['GET', 'POST'])
instance = None
if id:
instance = get_object_or_404(Lab, pk=id)
if request.method == 'GET':
form = MedicalLabForm(instance)
elif request.method == 'POST':
form = MedicalLabForm(request.POST, instance=instance)
if form.is_valid():
with transaction.commit_on_success():
lab = form.save()
# Only add lab, main branch in new lab creation
if not instance:
request.user.lab = lab
request.user.save()
Branch.create_main_branch(lab)
return render(request, 'add_update.html', {'form':form})