In my views.py I had things like that:
...
if mymodel.name == 'Myname1':
#do something
elif mymodel.name == 'Myname2':
#do something else
...
but I didn't like it because if Myname change I should search all my code to correct it, so I create a file where I keep all this words:
hardcoded_words.py:
myname1='Myname1'
myname1='Myname2'
myname1='Myname3'
...
and my views.py become:
from myapp import hardcoded_words
...
if mymodel.name==hardcoded_words.myname1:
#do something
elif mymodel.name==hardcoded_words.myname2:
#do something else
...
If Myname1 changes I need to correct just one file:
hardcoded_words.py:
...
myname1='Myname1_b'
...
Maybe there's some better way (fell free to tell) but the problem is with Javascript. There's a way to do something like that?
My javascript.js:
function myfunction1(myvariable1, myvariable2) {
switch (myvariable1) {
case 'Myname1':
//do something
break;
case 'Myname2':
//do something else
break;
...
Thank you for your help