Django-Cart,无法让它正常工作

时间:2011-12-07 02:57:53

标签: python django django-models django-admin django-forms

我正在尝试在我的项目中安装此软件包:

https://github.com/bmentges/django-cart

我根本无法将其用于工作。我有自己的项目模型,它与测试单元中提供的模型不同。有人能告诉我一个有效的例子,以便我可以自己尝试实现这个吗?

我按照步骤创建了一个视图,但是当我到达.add到购物车时,我得到了一个例外,甚至传递了正确的参数。

def cart_add(request):
if 'add' in request.GET:

    item_id = request.GET['add']

    print request

    try:
        print "GETTING object", item_id
        item=Item.objects.get(id=item_id)
    except Exception:
        raise Http404('Item you wished to add to add to cart was not found (maybe has been sold?)')

    user_obj = User.objects.get(username=request.user)
    profile = user_obj.profile

    #if item_id in profile.wishlist_items:
     #   raise Http404('Chosen item is already in your Cart!')
    try:
        cart=Cart(request)
    except Exception:
        raise Http404('bad cart')


    try:
        cart.add(item,Decimal(item.worth))
    except Exception:
        raise Http404('Problem adding item to Cart')

return HttpResponseRedirect('/')

我被困在“问题添加项目到购物车购物车”

0 个答案:

没有答案