Can I detect if my code is running on cPython or Jython?

后端 未结 5 974
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 00:49

I\'m working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I

5条回答
  •  有刺的猬
    2020-12-07 01:24

    You'll have unique settings.py for every different environment.

    Your development settings.py should not be your QA/Test or production settings.py.

    What we do is this.

    We have a "master" settings.py that contains the installed apps and other items which don't change much.

    We have environment-specific files with names like settings_dev_win32.py and settings_qa_linux2.py and 'settings_co_linux2.py`, etc.

    Each of these environment-specific settings imports the "master" settings, and then overrides things like the DB driver. Since each settings file is unique to an environment, there are no if-statements and no detecting which environment we're running in.

    Production (in Apache, using mod_wsgi and mysql) uses the settings_prod_linux2.py file and no other.

    Development (in Windows using sqlite) uses the settings_dev_win32.py file.

提交回复
热议问题