Django: is there a simple way to store choices on the database

Viewed 465

Seems basic as a need but I cannot find a way to store Django choices (the actual list of tuples) in database.

My use case it that I have a Django app with multiple models and fields with choices. At the app level, I can always get the mapping from field value using get_foo_display or accessing the tuple, but it seems that it’s not actually stored on the DB. Considering that I connect to the DB directly for some stats and BI, I’m missing the mapping for my analysis and reports.

Unless there’s some technique to do so, I guess I’ll create a « supporting » model to store the mappings. I would really appreciate your inputs/thoughts.

Thank you.

0 Answers
Related