Django: Using get_or_create to prevent race conditions

get_or_create, is an awesome helper utility to have at your disposal when you need an object matching some specifications, but there should only be exactly one match — you want to retrieve it if it already exists, and create it if it doesn’t.

However, there’s a scenario where it doesn’t quite do what we expect in the case of race conditions (exactly the thing we’re…

Senior Software Engineer |

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Keep Community Fellowships and Developer Grants

HotFix for Dragonary 2.3.0

Add Compose in XML (Interoperability) — Part 2

Shaping Engineering Culture In A Chaotic Environment — Part 1

The Future of Mobile App Development in Saudi Arabia

Microsoft Defender Endpoint Deployments

Microsoft Defender Endpoint Deployments

Spam or Ham? Test your message here.

Wisdom that Bootcamps Charge Five Digit Figures For, Free of Charge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrienne Domingus

Adrienne Domingus

Senior Software Engineer |

More from Medium

Build and Deploy Machine Learning Pipelines on AWS EC2 using Flask, Docker, Kubernetes, Gunicorn…

[Solved] django.db.utils.OperationalError: (2026, ‘SSL connection error: unknown error number’)

Currencylayer API data to Pandas Dataframe

Redis with Python