def teacher_add(request): if request.method == "POST": form = TeacherForm(request.POST) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = TeacherForm() variables = RequestContext(request, {"form": form}) return render_to_response("crud/teacher/teacher_add.html", variables)
def teacher_edit(request, id): teacher = Teacher.objects.get(pk=id) if request.method == "POST": form = TeacherForm(request.POST, instance=teacher) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = TeacherForm(instance=teacher) variables = RequestContext(request, {"form": form}) return render_to_response("crud/teacher/teacher_edit.html", variables)
def teacher_add(request): if request.method == 'POST': form = TeacherForm(request.POST) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = TeacherForm() variables = RequestContext(request, {'form': form}) return render_to_response('crud/teacher/teacher_add.html', variables)
def teacher_edit(request, id): teacher = Teacher.objects.get(pk=id) if request.method == "POST": form = TeacherForm(request.POST, instance=teacher) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = TeacherForm(instance=teacher) variables = RequestContext(request, {'form': form}) return render_to_response("crud/teacher/teacher_edit.html", variables)