在django中一次删除多个选定对象

时间:2019-06-27 09:02:53

标签: python jquery html django

我想在django admin中创建类似的内容,在其中可以选择要删除的对象。 我假设我有django表单来选择要删除的对象

我的模型如下:

class People(models.Models):
    names=models.Charfield

view.py

def display(request):
    people=People.objects.all()
    context={'people':people}

def delete_objs(request,id):
    # as per my knowledge, this can delete just one object per call.
    # I need a code where by i can delete multiple selected object ids at once
    objects.filter(id=id).delete()
    # I am stuck on how to implement a code that will delete selected objects    

在我的Django模板中:

{% for obj in people %}

 {{obj.name}} 

{% endfor %}

在我的django模板和视图中,如何使用户能够选择和删除所选对象?

0 个答案:

没有答案