From: Kriti Godey Date: Thu, 18 Mar 2010 21:57:29 +0000 (-0400) Subject: minor fixes X-Git-Url: http://git.ithinksw.org/~kgodey/maayanwich.git/commitdiff_plain/da28c6fb169effe61e783f01b1f26d614d96f0e8 minor fixes --- diff --git a/views.py b/views.py index 554fbac..e47a17f 100644 --- a/views.py +++ b/views.py @@ -63,24 +63,24 @@ def edit_sandwich(request, slug): if request.method == 'POST': sform = SandwichForm(request.POST, request.FILES, instance=sedit) if sform.is_valid(): # All validation rules pass - sform.save() + newsandwich = sform.save() x = request.POST['ing'] x = x.strip() y = x.split(',') for n in y: if n.isdigit(): - sedit.ingredients.add(Ingredient.objects.get(id=n)) + newsandwich.ingredients.add(Ingredient.objects.get(id=n)) else: n = n.lstrip('new:') newingredient = Ingredient(name=n, slug=SlugifyUniquely(n, Ingredient)) newingredient.save() - sedit.ingredients.add(newingredient) - if not sedit.picture: + newsandwich.ingredients.add(newingredient) + if not newsandwich.picture: if savedpicture: - sedit.picture = savedpicture - sedit.slug = slug - sedit.save() - return HttpResponseRedirect(sedit.get_absolute_url()) + newsandwich.picture = savedpicture + newsandwich.slug = slug + newsandwich.save() + return HttpResponseRedirect(newsandwich.get_absolute_url()) else: sform = SandwichForm(instance=sedit) return render_to_response('editsandwich.html', {'sform': sform, 's':sedit,}, context_instance=RequestContext(request))