Python 从django oscar的篮子中取出物品

Python 从django oscar的篮子中取出物品,python,django,django-oscar,Python,Django,Django Oscar,在django oscar中,如何从客户的购物篮中取出物品 以下行仅用作链接: <a href="#" data-id="{{ forloop.counter0 }}" data-behaviours="remove" class="inline">{% trans "Remove" %}</a> 在Python中,如果您知道要删除的项目的行: request.basket.items[line].delete() request.basket.save() 在Jav

在django oscar中,如何从客户的购物篮中取出物品

以下行仅用作
链接:

<a href="#" data-id="{{ forloop.counter0 }}" data-behaviours="remove" class="inline">{% trans "Remove" %}</a>

在Python中,如果您知道要删除的项目的行:

request.basket.items[line].delete()
request.basket.save()
在JavaScript中,查看 对于触发项目删除的代码行:

$('#content_inner').on('click', '#basket_formset a[data-behaviours~="remove"]', function(event) {
    o.basket.checkAndSubmit($(this), 'form', 'DELETE');
    event.preventDefault();
});

一些可能更有用的阅读:and.

就像您处理任何Django模型实例一样,使用行的
delete
方法:
basket.all_line().filter(..).delete()
您的问题有点模糊。Oscar使用一些javascript从篮子中删除项目:$('a[data behaviors~=“delete”]')。单击(function(){o.notifications.checkAndSubmit($(this),'delete');}),checkAndSubmit:function($ele,btn_val){$ele.closest('tr').find('input').attr('checked','checked');$ele.closest('form').find('button[value=“'+btn_val+'”)。click();return false;};