Пример #1
0
def addCourseForm(request):
    if request.method == "POST":
        form = GolfCourseForm(request.POST)
        if form.is_valid():
            model_instance = form.save()
            return redirect('golfstats.list-courses')
    else:
        form = GolfCourseForm()
    return render(request, 'golfstats/add-course.html', {'form': form})
Пример #2
0
def modifyCourseForm(request, course_id):
    course = GolfCourse.objects.get(pk=golfer_id)
    if request.method == "POST":
        form = GolfCourseForm(request.POST, instance=course)
        if form.is_valid():
            model_instance = form.save()
            return redirect('golfstats.list-courses')
    else:
        form = GolfCourseForm(instance=course)
    return render(request, 'golfstats/modify-course.html', {'course_id': golfer_id, 'form': form})