def department_add(request): if request.method == 'POST': form = DepartmentForm(request.POST) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = DepartmentForm() variables = RequestContext(request, {'form': form}) return render_to_response('crud/department/department_add.html', variables)
def department_add(request): if request.method == "POST": form = DepartmentForm(request.POST) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = DepartmentForm() variables = RequestContext(request, {"form": form}) return render_to_response("crud/department/department_add.html", variables)
def department_edit(request, id): department = Department.objects.get(pk=id) if request.method == "POST": form = DepartmentForm(request.POST, instance=department) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = DepartmentForm(instance=department) variables = RequestContext(request, {'form': form}) return render_to_response("crud/book/department_edit.html", variables)
def department_edit(request, id): department = Department.objects.get(pk=id) if request.method == "POST": form = DepartmentForm(request.POST, instance=department) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = DepartmentForm(instance=department) variables = RequestContext(request, {"form": form}) return render_to_response("crud/book/department_edit.html", variables)