我想在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模板和视图中,如何使用户能够选择和删除所选对象?