2👍
✅
What I usually do is create a specific app for that. So a tools
app, for instance, in which I either define a choices.py
, in which I hardcode the choices and then import them whereever I need them.
Alternatively, you can create a simple model, in which you can create them yourself. Then you can use __init__
functions to append them to a specific field. However, that solution will be overly complicated though, since you need to append those on runtime.
The easiest solution is to just create a hardcoded choices.py
. I’ve tried what you are trying to do once, and it turned out to be a huge mess. So unless you REALLY need it, I would advise to just manually manage a choices.py
file.
👤Özer
Source:stackexchange.com