def task_create(request): if request.method == "POST": form = TodoItemForm(request.POST) if form.is_valid(): form.save() return reverse("tasks:list") else: form = TodoItemForm() return render(request, "tasks/create.html", {"form": form})
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): form.save() return redirect("/tasks/list") return render(request, "tasks/create.html", {"form": form})
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): form.save(commit=False).owner = request.user form.save() return redirect(reverse('tasks:list')) return self.my_render(request, form)
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() return HttpResponseRedirect(reverse("tasks:list")) return render(request, "tasks/create.html", {"form": form})
def post(self, request, pk, *args, **kwargs): t = ToDoItem.objects.get(id=pk) form = TodoItemForm(request.POST, instance=t) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() return HttpResponseRedirect(reverse("tasks:list")) return render(request, "tasks/edit.html", {"form": form, "task": t})
def post(self, request, pk, *args, **kwargs): task = TodoItem.objects.get(id=pk) form = TodoItemForm(request.POST, instance=task) if form.is_valid(): updated_task = form.save(commit=False) updated_task.owner = request.user updated_task.save() return redirect(reverse('tasks:list')) return self.create_render(request, form, task)
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() messages.success(request, 'Задача добавлена') return redirect(reverse('tasks:list')) return self.my_render(request, form)
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() # return redirect("/tasks/list") return redirect(reverse("tasks:list")) return self.my_render(request, form)
def post(self, request, pk, *args, **kwargs): t = TodoItem.objects.get(id=pk) form = TodoItemForm(request.POST, instance=t) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() messages.success(request, 'Задача изменена') return redirect(reverse('tasks:list')) return render(request, 'tasks/edit.html', {'form': form, 'task': t})
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() form.save_m2m() messages.success(request, 'Задача создана') return redirect(reverse('tasks:list')) return render(request, 'tasks/create.html', {'form': form})
def post(self, request, pk, *args, **kwargs): t = TodoItem.objects.get(id=pk) form = TodoItemForm(request.POST, instance=t) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() messages.success(request, "Задача отредактирована") return redirect(reverse("tasks:list")) return render(request, "tasks/edit.html", {"form": form, "task": t})
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() form.save_m2m() messages.success(request, new_task.description + " Задача добавлена") return redirect(reverse("tasks:list")) # return redirect("/tasks/list") return render(request, "tasks/create.html", {"form": form})
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): # form.save() # return redirect("tasks:list") #добавляем владельца задачи new_task = form.save(commit=False) new_task.owner = request.user new_task.save() form.save_m2m() return redirect(reverse("tasks:list")) return self.my_render(request, form)
def post(self, request, *args, **kwargs): form = TodoItemForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.owner = request.user new_task.save() form.save_m2m() messages.success(request, 'Задача добавлена') if form.cleaned_data['trello_sync']: user = request.user key = user.profile.trello_key secret = user.profile.trello_secret client = TrelloClient(api_key=key, api_secret=secret) board = client.get_board(user.profile.trello_board) to_do = board.list_lists()[0] to_do.add_card(new_task.description) return redirect(reverse('tasks:list')) return self.my_render(request, form)
def get(self, request, *args, **kwargs): form = TodoItemForm() return self.my_render(request, form)
def get(self, request, pk, *args, **kwargs): t = ToDoItem.objects.get(id=pk) form = TodoItemForm(instance=t) return render(request, "tasks/edit.html", {"form": form, "task": t})
def get(self, request, *args, **kwargs): form = TodoItemForm() return render(request, 'tasks/create.html', {'form': form})
def get(self, request, pk, *args, **kwargs): task = TodoItem.objects.get(id=pk) form = TodoItemForm(instance=task) return self.create_render(request, form, task)
def get(self, request, pk, *args, **kwargs): t = TodoItem.objects.get(id=pk) form = TodoItemForm(instance=t) return render(request, 'tasks/edit.html', {'form': form, 'task': t})
def get(self, request, *args, **kwargs): form = TodoItemForm() return render(request, "tasks/create.html", {"form": form})
def get(self, request, pk, *args, **kwargs): t = TodoItem.objects.get(id=pk) form = TodoItemForm(instance=t) return self.my_render(request, form, t)