I really, really like the django_enum package.

Imagine Django's TextChoices/IntegerChoices classes, but with the ability to encapsulate any additional information for each choice in one place.

I don't use it everywhere, but it's super useful in a number of use-cases.

Here are a few places where I've found django_enum makes things easier. See alt text for more detail about how I use of each of these.

Check it out: https://django-enum.readthedocs.io/en/stable/

And follow: @bckohan

#Django #Python #WebDev #Enums

Django Enum 2.2.2 documentation

@jack @bckohan Very cool, and also great use of fmt:off/on !
@jack @bckohan Wow, awesome examples! What's a reason you prefer an Enum over a database model? I can think of a couple models in my database that could be replaced with an Enum.

@jonathanbiemond @bckohan Mainly cases where the data is unlikely to change much in the future & is more "fact" than something I might make adjustments to regularly.

For instance, each field in my Terminology model covers pretty much every term variation that I've found in literature or in practice. It's sort of one-and-done.

Likewise, while new linings may be developed over time for waterways, it's unlikely they will be in common use anytime soon, and I've covered most existing cases.

@jack @jonathanbiemond I'm glad you're finding it useful Jack! The motivation for it was from my work in satellite navigation. An engineering field similarly full of enumerated lists of hardware!
@bckohan @jack @jonathanbiemond I find it useful as well, I've been using it in q few projects!