def update_course(request, course_id): course = get_object_or_404(Course, id=course_id) if request.method == "GET": course_form = CourseForm(instance=course) if request.method == "POST": course_form = CourseForm(request.POST, instance=course) if course_form.is_valid(): course = course_form.save() context = RequestContext(request, {"course": course, "course_form": course_form}) return render('checkin/update_course.html', context)
def create_course(request): if request.method == "GET": course_form = CourseForm() context = RequestContext(request, {'course_form': course_form}) else: course_form = CourseForm(request.POST) if course_form.is_valid(): course = course_form.save() context = RequestContext(request, {'course_form': course_form, 'course': course}) else: context = RequestContext(request, {'course_form': course_form}) return render('checkin/create_course.html', context)