- Django 2 by Example
- Antonio Melé
- 47字
- 2021-06-25 21:19:01
Deleting objects
If you want to delete an object, you can do it from the object instance using the delete() method:
post = Post.objects.get(id=1)
post.delete()
Note that deleting objects will also delete any dependent relationships for ForeignKey objects defined with on_delete set to CASCADE.