new library: django-spicy-id: Automatic "stripe-style" primary key row IDs

Hi everyone! Sharing a new library I wrote here, in case someone else finds it useful. I am using it in production. It’s called django-spicy-id and you can check it out here:

Brief summary: It provides subclasses of models.AutoField that represent these values as a string with a prefix instead of a number.

So anywhere you refer to a primary key (for example, in a log file or URL), you would see and use something like user_1234 instead of the naked value 1234.

So why do this? There’s some explanation in the readme, it boils down to “it makes a lot of things more human to the developer”. I’ve used this technique and an earlier version of this code at very large scale, and the methodology routinely received positive remarks from engineers. Having said this, it’s ultimately a matter of taste and opinion - nobody needs to structure their IDs this way.

I’m more of a lurker here, but I welcome any feedback or questions, here or in the repo. There are some tests in the repo which illustrate its use as well. Enjoy!

Neat project! It’s nicely documented as well.

1 Like

Thanks much! It was fun to write… and use!