Django 3 : Deleting objects

Deleting a record

Step 1To delete a record in the database, we must use the delete() method. Removing items is easier than changing items, because the method is the same for a queryset as for the instances of models. An example of this is as follows

Step 2 : The code template

Step 3 : Now start the development server with the python manage.py runserver command and open http://127.0.0.1:8000/page/ in your browser.

Deleting multiple records

Step 4 : To delete multiple records in one shot, you must use the delete() method with a queryset object type