本文整理汇总了Python中forms.ProjectForm.if_dup方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectForm.if_dup方法的具体用法?Python ProjectForm.if_dup怎么用?Python ProjectForm.if_dup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.ProjectForm
的用法示例。
在下文中一共展示了ProjectForm.if_dup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_project
# 需要导入模块: from forms import ProjectForm [as 别名]
# 或者: from forms.ProjectForm import if_dup [as 别名]
def new_project(request):
if request.method == 'POST':
form = ProjectForm(request.POST)
name = str(request.POST['title'])
#list=(str(project_api.get_projects_for_user(request.user.id))).replace("<Project: ","").replace(', ','').replace('[','').replace("]",'').split('>')
#list = project_api.get_projects_for_user(request.user.id).values_list('title',flat=True)
#print list
#if name in list:
if project_api.duplicate_project(request.user,request.POST):
form.if_dup(1)
if form.is_valid() :
project_api.create_project(request.user, request.POST)
project = form.save(commit=False)
# return redirect('/req/projects')
# return empty string and do the redirect stuff in front-end
return HttpResponse('')
else:
form = ProjectForm()
context = {'projects': project_api.get_projects_for_user(request.user.id),
'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
'title': 'New Project',
'form': form, 'action': '/req/newproject', 'button_desc': 'Create Project'}
return render(request, 'ProjectSummary.html', context)