I think what you want is the newforms 'prefix' option. I can't seem to find it in the docs though, so here is an example. It seems a little strange to be saving forms in the session, and I can't see how your quantity updates can happen if you don't access POST in the update_quantity view at all. Here is how I would expect your views to work, combining them into one. Prefix relies on having a unique identifier specified for each item, below I treated items like it was a django model and used the _get_pk_val() method (which returns the primary key) for the identifier. Since yours are not models, you'll have to come up with something yourself.
def cart_view(request): cart = request.session.get('cart',Cart()) if request.POST: for item in cart.items: form=FormForItemQuantity(request.POST,prefix=item._get_pk_val()) if form.is_valid(): item.quantity = int(form.cleaned_data['quantity']) request.session['cart'] = cart return HttpResponseRedirect('/carts/show/') # redirect after post else: # bind form with current values for item in cart.items: form=FormForItemQuantity({'quantity':item.quantity},prefix=item._get_pk_val()) return render_to_response('show_cart.html', {'cart':cart,'num_items': cart.total_items}) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---