Django simple shopping cart, tests and south migrations included
Project description
# Introduction
django-cart is a very simple application that just let you add and remove items from a session based cart. django-cart uses the power of the Django content type framework to enable you to have your own Product model and associate with the cart without having to change anything. Please refer to the tests to see how it's done.
## Prerequisites
- Django 1.1+
- django content type framework in your INSTALLED_APPS
## Installation
To install this just type:
```
python setup.py install
```
After installing it, just add 'cart' to your installed apps and you're good to go.
## Usage
A basic usage of django-cart could be (example):
```python
# views.py
from cart import Cart
from myproducts.models import Product
def add_to_cart(request, product_id, quantity):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.add(product, product.unit_price, quantity)
def remove_from_cart(request, product_id):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.remove(product)
def get_cart(request):
return render_to_response('cart.html', dict(cart=Cart(request)))
```
```django
# templates/cart.html
{% extends 'base.html' %}
{% block body %}
<table>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
{% for item in cart %}
<tr>
<td>{{ item.product.name }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.total_price }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
```
## Some Info
This project was abandoned and I got it and added tests and South migrations, and I will be maintaining it from now on.
## Known Problems
Right now the main problem is that it adds a database record for each cart it creates. I'm in the process of studying this and will soon implement something to handle it.
## A note on the authors of this project
This project is a fork of [django-cart](http://code.google.com/p/django-cart/ "django-cart") on Google Code. It was originally started by Eric Woudenberg and followed up by Marc Garcia <http://vaig.be>. The last change ocurred in March 25 2009, without any tests. My goal is to push this project a little further by adding tests to guarantee it's functionality and to fix the main issues. I intend to keep it as simple as it is.
- Bruno Carvalho
django-cart is a very simple application that just let you add and remove items from a session based cart. django-cart uses the power of the Django content type framework to enable you to have your own Product model and associate with the cart without having to change anything. Please refer to the tests to see how it's done.
## Prerequisites
- Django 1.1+
- django content type framework in your INSTALLED_APPS
## Installation
To install this just type:
```
python setup.py install
```
After installing it, just add 'cart' to your installed apps and you're good to go.
## Usage
A basic usage of django-cart could be (example):
```python
# views.py
from cart import Cart
from myproducts.models import Product
def add_to_cart(request, product_id, quantity):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.add(product, product.unit_price, quantity)
def remove_from_cart(request, product_id):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.remove(product)
def get_cart(request):
return render_to_response('cart.html', dict(cart=Cart(request)))
```
```django
# templates/cart.html
{% extends 'base.html' %}
{% block body %}
<table>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
{% for item in cart %}
<tr>
<td>{{ item.product.name }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.total_price }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
```
## Some Info
This project was abandoned and I got it and added tests and South migrations, and I will be maintaining it from now on.
## Known Problems
Right now the main problem is that it adds a database record for each cart it creates. I'm in the process of studying this and will soon implement something to handle it.
## A note on the authors of this project
This project is a fork of [django-cart](http://code.google.com/p/django-cart/ "django-cart") on Google Code. It was originally started by Eric Woudenberg and followed up by Marc Garcia <http://vaig.be>. The last change ocurred in March 25 2009, without any tests. My goal is to push this project a little further by adding tests to guarantee it's functionality and to fix the main issues. I intend to keep it as simple as it is.
- Bruno Carvalho
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-cart-1.0.0.tar.gz
(5.2 kB
view hashes)
Built Distribution
django_cart-1.0.0-py2.6.egg
(13.2 kB
view hashes)