Most developers know a thing or two about multi-threading and concurrent programming. But the database often is treated as a black box not behaving as we expect it to and leading to weird bugs. We will look at concurrency in the database through programming language concepts and try to understand what happens behind the scenes of pessimistic and optimistic locking. We will discover how to use Django ORM and database locking and blocking to achieve correct, concurrent, and performant database updates.