You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Because I use many of the same constants in different apps in my project
I keep most of them including almost all choices in a single __init__.py
file and import them wherever required.
Here is a tiny utility I use all the time ... whenever
get_<fieldname>_display() is inappropriate.
def choose(choices, choice):
for pair in choices:
if pair[0] == choice:
return pair[1]
for section in choices:
for pair in section[1]:
if pair[0] == choice:
return pair[1]
Hope someone finds it useful. Also, I'm sure it can be made much more
pythonic. It is Friday after all :)