minor fixes
authorKriti Godey <kriti.godey@gmail.com>
Thu, 18 Mar 2010 21:57:29 +0000 (17:57 -0400)
committerKriti Godey <kriti.godey@gmail.com>
Thu, 18 Mar 2010 21:57:29 +0000 (17:57 -0400)
views.py

index 554fbac..e47a17f 100644 (file)
--- 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))