def add(request): if request.method == "POST": task_name = request.POST['task'] new_task = Task() new_task.name = task_name new_task.completed = False new_task.save() return redirect('/')
def add_task(request): if request.method == "POST": task_name = request.POST.get('task_name') now = timezone.now() task = Task(name=task_name, added_time=now) task.save() response = redirect('/todoapp/') return response
def add(request): task1 = Task.objects.all() if request.method == 'POST': Name = request.POST.get('tname', '') Priority = request.POST.get('tpriority', '') Date = request.POST.get('tdate', '') task = Task(task_Name=Name, task_priority=Priority, task_Date=Date) task.save() return render(request, 'home.html', {'task1': task1})
def task_view(request): if request.method=="POST": name=request.POST.get('name') priority= request.POST.get('priority') date=request.POST.get('date') obj=Task(name=name,priority=priority,date=date) obj.save() obj1=Task.objects.all() return render(request, 'taskview.html', {'obj11': obj1})
def save_task(request,user_id): data= json.loads(request.body) tTitledata = data.get('tTitle') tDescdata=data.get('tDesc') tStatusdata = data.get('tStatus') tAccessdata=data.get('tAccess') print tAccessdata userObject=User.objects.get(id=user_id) taskObject= Task(user=userObject, tTitle=tTitledata, tDesc=tDescdata, tStatus=tStatusdata, tAccess=tAccessdata) if taskObject: taskObject.save() return tasks(request,user_id)
def create_task(title, desc, tags, **kwargs): """ Handler is FOr creating Task """ if isinstance(title, list): title = title[0] if isinstance(desc, list): desc = desc[0] if isinstance(tags, list): tags = tags[0] if tags: tags = map(lambda x: x.strip(), tags.split(',')) for _tag in tags: create_tag(_tag) try: _task = Task(title=title, desc=desc, tags=tags) _id = _task.save() except Exception, e: raise e