Hi Guys,
I've update my site from django 1.3 to 1.5
The site works fine, except for a view, the template renders before the obj.save() in the view:
def cart(request):
try:
cart = Cart.objects.prefetch_related('cartitem_set__product__category').get(id=request.session['cart_id'])
except (KeyError, Cart.DoesNotExist) as e:
cart = Cart()
cart.save()
request.session['cart_id'] = cart.id
if 'add' in request.GET:
try:
product = Product.objects.get(slug=request.GET['add'], active=True)
cart_item = CartItem.objects.get(product=product, cart=cart)
except CartItem.DoesNotExist:
cart_item = CartItem(product=product, cart=cart)
cart_item.save()
except Product.DoesNotExist:
pass
response_args = {'cart': cart}
return render_to_response('products/cart.html', response_args, context_instance=RequestContext(request))
I don't know why this happens
any help? something has changed? now the database save is async?