本文整理匯總了Python中projects.forms.ProjectForm.save_m2m方法的典型用法代碼示例。如果您正苦於以下問題:Python ProjectForm.save_m2m方法的具體用法?Python ProjectForm.save_m2m怎麽用?Python ProjectForm.save_m2m使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類projects.forms.ProjectForm
的用法示例。
在下文中一共展示了ProjectForm.save_m2m方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: new_project
# 需要導入模塊: from projects.forms import ProjectForm [as 別名]
# 或者: from projects.forms.ProjectForm import save_m2m [as 別名]
def new_project(request):
if request.method == 'POST':
project = Project()
form = ProjectForm(request.POST, instance=project)
if form.is_valid():
form.save(commit=False)
project.user = request.user
project.admingroup = request.organization.admingroup
project.save()
form.save_m2m()
return HttpResponseRedirect(project.get_absolute_url())
else:
project = Project()
form = ProjectForm(instance=project)
return render_to_response('projects/new_project.html', {'form': form}, context_instance=RequestContext(request))