跳转到主要内容

django-carton 是一个简单轻量级的购物车和愿望清单应用。

项目描述

  +------+
 /|     /|
+-+----+ |    django-carton helps you build your shopping
| |    | |    cart and which list functionality.
| +----+-+
|/     |/
+------+
  • 很简单:您决定如何实现视图、模板和支付处理。

  • 很轻量:购物车位于会话中。

  • 只是一个容器:您以您想要的方式定义产品模型。

使用示例

视图

from django.http import HttpResponse

from carton.cart import Cart
from products.models import Product

def add(request):
    cart = Cart(request.session)
    product = Product.objects.get(id=request.GET.get('product_id'))
    cart.add(product, price=product.price)
    return HttpResponse("Added")

def show(request):
    return render(request, 'shopping/show-cart.html')

我们假设您的产品定义在名为 products 的应用程序中。

模板

{% load carton_tags %}
{% get_cart as cart %}

{% for item in cart.items %}
    {{ item.product.name }}
    {{ item.quantity }}
    {{ item.total_price }}
{% endfor %}

You can also use this convinent shortcut:
{% for product in cart.products %}
    {{ product.name }}
{% endfor %}

文档

阅读更多: https://github.com/lazybird/django-carton/

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

django-carton-1.2.1.tar.gz (8.0 kB 查看哈希值)

上传时间:

由以下支持