def product_add(request): ProductForm = forms.form_for_model(Product) if request.method == 'POST': pf = ProductForm(request.POST.copy()) if pf.is_valid(): product = pf.save() return HttpResponseRedirect('/warehouse/products/%i/' % product.id) else: pf = ProductForm() return render_to_response( 'warehouse/product_add.html', {'form': pf.as_table()})