HKNBetaEpsilon / new-hkn-website

1 stars 4 forks source link

Figure out how to mange differences between Server and Repo Code #12

Closed nimmerman closed 5 years ago

nimmerman commented 8 years ago

Things like database settings should be different on the server versus in the repository

zhanghan177 commented 8 years ago

no the server versus in the repository

Can you elaborate it more?

nimmerman commented 8 years ago

The server uses mysql but it is convenient for testing to use sqllite. We need to have a nice way to switch or isolate the two settings. Right now the mysql changes have been made on the server and just not pushed anywhere but this is definitely not the best solution

manavgabhawala commented 7 years ago

A clean way to solve this problem is put common settings in settings.py like you have. Then make a file on the GitHub repo called development_settings.py and on the server only (don't add to git) make a file called production_settings.py. At the top of settings.py you can do:

try:
   from production_settings import *
except ImportError:
   from development_settings import *

Then, it will always pick the right settings. Also this way you can have the variables for secret keys etc, visible but the actual values will be hidden because production settings will have the right ones only. Also consider switching the server to postgres instead of mysql, it provides better support for things like arbitrarily long strings, native timezone support, etc. And ideally, the development and production would use the same db type so that errors don't occur when moving to a different db.

djmcalli commented 5 years ago

Resolved with the fix suggested by manavgabhawala. Could also look into changing SECRET to come from development_settings or production_settings, as well. The issue would be individual 'try' sections for each element to maintain modularity (overwriting 'default' values), but this would likely be more appearance than performance.