本文整理汇总了Python中tasks.models.Task.project方法的典型用法代码示例。如果您正苦于以下问题:Python Task.project方法的具体用法?Python Task.project怎么用?Python Task.project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.project方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_project_task
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import project [as 别名]
def add_project_task(request,slug):
if request.user.is_authenticated():
project = Project.objects.get(slug = slug)
if request.POST:
form = TaskForm(request.POST)
if form.is_valid():
data = form.cleaned_data
td = data['end_date'] - data['start_date']
if td.total_seconds()>0:
task = Task()
task.name = data['name']
task.description = data['description']
task.start_date = data['start_date']
task.end_date = data['end_date']
task.user = data['user']
task.project = project
task.save()
else:
messages.add_message(request, messages.ERROR,
" end date is less than start date!")
return (redirect(reverse('Task:add_task')))
return (redirect(reverse('Home:manager')))
else:
messages.add_message(request, messages.ERROR,
"invalid form")
return (redirect(reverse('Task:add_task')))
else:
form = TaskForm()
send_dict={}
context_instance=RequestContext(request)
send_dict['project'] = project
send_dict['form'] = form
return render_to_response('tasks/add_task.html',send_dict,context_instance)
else:
return redirect(reverse('Login:login'))