def get_or_create_db_cart(cart_queryset=Cart.objects.all()):
 def get_cart(view):
  @wraps(view)
  def func(request, *args, **kwargs):
   cart = get_or_create_cart_from_request(request, cart_queryset)
   response = view(request, cart, *args, **kwargs)
   if (not request.user.is_authenticated()):
    set_cart_cookie(cart, response)
   return response
  return func
 return get_cart

def get_or_create_db_cart ( cart_queryset = Cart . objects . all ( ) ) : def get_cart ( view ) : @ wraps ( view ) def func ( request , * args , ** kwargs ) : cart = get_or_create_cart_from_request ( request , cart_queryset ) response = view ( request , cart , * args , ** kwargs ) if ( not request . user . is_authenticated ( ) ) : set_cart_cookie ( cart , response ) return response return func return get_cart
get cart or create if necessary .