From 291330c9f774b535195e21bdefa26c83274d4235 Mon Sep 17 00:00:00 2001 From: Vinicio Valbuena Date: Sat, 9 Dec 2017 18:39:18 -0500 Subject: [PATCH 1/3] fix templatetags --- carton/templatetags/carton_tags.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/carton/templatetags/carton_tags.py b/carton/templatetags/carton_tags.py index 397aa8c..eacb44f 100644 --- a/carton/templatetags/carton_tags.py +++ b/carton/templatetags/carton_tags.py @@ -6,7 +6,7 @@ register = template.Library() - +@register.simple_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME) def get_cart(context, session_key=None, cart_class=Cart): """ Make the cart object available in template. @@ -22,4 +22,3 @@ def get_cart(context, session_key=None, cart_class=Cart): request = context['request'] return cart_class(request.session, session_key=session_key) -register.assignment_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME)(get_cart) From 96f944bed9470bd04309ac562b86457c9dd69b69 Mon Sep 17 00:00:00 2001 From: Vinicio Valbuena Date: Sat, 9 Dec 2017 22:39:17 -0500 Subject: [PATCH 2/3] support for django 2.0 --- carton/templatetags/carton_tags.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/carton/templatetags/carton_tags.py b/carton/templatetags/carton_tags.py index eacb44f..757124c 100644 --- a/carton/templatetags/carton_tags.py +++ b/carton/templatetags/carton_tags.py @@ -6,7 +6,6 @@ register = template.Library() -@register.simple_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME) def get_cart(context, session_key=None, cart_class=Cart): """ Make the cart object available in template. @@ -22,3 +21,8 @@ def get_cart(context, session_key=None, cart_class=Cart): request = context['request'] return cart_class(request.session, session_key=session_key) +try: + register.simple_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME)(get_cart) +except ImportError: + register.assignment_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME)(get_cart) + From 75a0b771a4d61e4f71f152c1efc95835aa317eeb Mon Sep 17 00:00:00 2001 From: Vinicio Valbuena Date: Mon, 11 Dec 2017 07:57:52 -0500 Subject: [PATCH 3/3] fix try for templatetag --- carton/templatetags/carton_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/carton/templatetags/carton_tags.py b/carton/templatetags/carton_tags.py index 757124c..1992eee 100644 --- a/carton/templatetags/carton_tags.py +++ b/carton/templatetags/carton_tags.py @@ -23,6 +23,6 @@ def get_cart(context, session_key=None, cart_class=Cart): try: register.simple_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME)(get_cart) -except ImportError: +except: register.assignment_tag(takes_context=True, name=CART_TEMPLATE_TAG_NAME)(get_cart)