def meeting_update(request, id, template_name="customer/meeting_update.html"): meeting = Meeting.objects.get(id=id) form = MeetingForm(request.POST or None, instance=meeting) if form.is_valid(): form.save() return redirect("meeting_list") return render(request, template_name, {"form": form})
def meeting_create(request, id, template_name="customer/meeting_add.html"): customer = get_object_or_404(Customer, id=id) initial = {"customer": customer} form = MeetingForm(request.POST or None, initial=initial) if form.is_valid(): meeting = form.save(commit=False) meeting.customer = customer meeting.customer_id = id meeting.save() return redirect("customer") return render(request, template_name, {"form": form})