Skip to content
Justice Tech School

Update and Delete

Change attributes then save, or use update() for many rows at once. delete() removes objects.

Example
p = Post.objects.get(id=1)
p.title = "New title"
p.save()

Post.objects.filter(title="Old").update(title="Fresh")
Post.objects.filter(id=3).delete()

Exercise

Remove objects.

Post.objects.filter(id=3).()

Quiz Test

What does update() return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.