From 115ce498fd24beea9459ec98a9f04cf02ab9e202 Mon Sep 17 00:00:00 2001 From: "jorge.alfonso" Date: Thu, 7 May 2020 23:51:20 -0400 Subject: [PATCH] Custom session cookie name Gives the user the option to name the session cookie of the cart --- README.md | 6 ++++++ cart/cart.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd05261..295cda2 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ After installation is complete: A basic usage of django-cart could be (example): +```python +# settings.py + +CART_ID = 'CART_ID' # set the name of your session cookie for the cart +``` + ```python # views.py from cart.cart import Cart diff --git a/cart/cart.py b/cart/cart.py index 332d157..8f0de88 100644 --- a/cart/cart.py +++ b/cart/cart.py @@ -1,9 +1,13 @@ import datetime from django.db.models import Sum from django.db.models import F +from django.conf import settings from . import models -CART_ID = 'CART-ID' +if settings.CART_ID: + CART_ID = settings.CART_ID +else: + CART_ID = 'CART-ID' class ItemAlreadyExists(Exception):