Skip to main content

django-carton is a simple and lightweight application for shopping carts and wish lists.

Project description

  +------+
 /|     /|
+-+----+ |    django-carton helps you build your shopping
| |    | |    cart and which list functionality.
| +----+-+
|/     |/
+------+
  • It’s simple: You decide how to implement the views, templates and payment processing.

  • It’s lightweight: The cart lives in the session.

  • It’s just a container: You define your product model the way you want.

Usage Example

View:

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')

We are assuming here that your products are defined in an application called products.

Template:

{% 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 %}

Documentation

Read more: https://github.com/lazybird/django-carton/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-carton-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file django-carton-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django-carton-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2f41989cf653bb07082e7a132e80f1e2c2990c807449fd4a299c0c5adfcfdab2
MD5 a7393e0d26fc724d25b12b806effca23
BLAKE2b-256 614d9864dac189c6e7b0578d0d8c62eed6ea5bb54cc66fcab51f2197fe5560a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page