From d0eaa41bb138f3526d81841f888457c47508a23f Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 20 Jul 2012 03:31:17 +0530 Subject: [PATCH] if form save is successful, redirect --- itf/itfprofiles/views.py | 7 ++++++- itf/templates/test/person_form.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/itf/itfprofiles/views.py b/itf/itfprofiles/views.py index 563ebd6..502e2e1 100644 --- a/itf/itfprofiles/views.py +++ b/itf/itfprofiles/views.py @@ -5,7 +5,7 @@ from django.shortcuts import render_to_response from ox.django.shortcuts import render_to_json_response from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.template import RequestContext -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from django.contrib.auth.decorators import login_required @@ -30,9 +30,14 @@ def edit_profile(request): if form.is_valid(): instance = form.save() form.save() + all_valid = True for inline in inlines: if inline.is_valid(): inline.save() + else: + all_valid = False + if all_valid: + return HttpResponseRedirect("/edit_profile/") else: form = PersonForm(instance=person) diff --git a/itf/templates/test/person_form.html b/itf/templates/test/person_form.html index f903eb0..039307e 100644 --- a/itf/templates/test/person_form.html +++ b/itf/templates/test/person_form.html @@ -77,7 +77,7 @@ $(function(){ } }); var id = $this.attr("data-id"); - console.log(id); + //console.log(id); if ($.trim(id) !== '') { var title = $this.attr("data-title"); $this.select2("val", {'id': id, 'title': title});