def update(request): form = TeamForm(request.user, request.POST, instance=request.team) if form.is_valid(): form.save() messages.success(request, "Your team was updated successfully") return redirect("/team") return render(request, "team/edit.html", {"form": form}, status=400)
def update(request): form = TeamForm(request.user, request.POST, instance=request.team) if form.is_valid(): form.save() messages.success(request, 'Your team was updated successfully') return redirect('/team') return render(request, 'team/edit.html', { 'form': form, }, status=400)
def edit(request): user = request.user team = request.team return render(request, 'team/edit.html', { 'form': TeamForm(request.user, instance=team), 'user': user, })
def edit(request): user = request.user team = request.team return render( request, "team/edit.html", {"form": TeamForm(request.user, instance=team), "user": user}, )
def new(request): # Don't use the middleware here, check manually. # If the user is on a team already, don't let them make a new one. if request.user.assigned_to_team(): messages.warning(request, "You're already assigned to a team") return redirect("/team") if request.method == "POST": form = TeamForm(request.user, request.POST) if form.is_valid(): form.save() messages.success(request, "Your team was created successfully") return redirect("/team") else: status = 400 else: status = 200 form = TeamForm(request.user) return render(request, "team/new.html", {"form": form}, status=status)