--- Title: '一括削除 #django' Keywords: - django Author: junshimo2 Web: https://mimemo.io/m/bRndWoOmQv4B965 --- # 一括削除 ### 一括削除のurls.py #### testapp/views/urls.py ``` python urlpatterns = [ #... path('batch_delete', UserView.batch_delete_view, name='batch_delete'), ] ``` ### 一括削除のtemplate #### testapp/templates/batch_delete.html ``` html
``` ### 一括削除の表示のview #### testapp/views/user_view.py ``` python def batch_delete_view(request): users = { 'users': AppUser.objects.all(), } return render(request, 'batch_delete.html', users) ``` ### 一括削除の削除処理のview #### testapp/views/user_view.py ``` python def batch_delete(ids): AppUser.objects.filter(id__in=ids).all().delete() return HttpResponseRedirect('/') ```