[Django]-Update sensitive code on Github and server?

4👍

Simple solutions is:

  • create settings_local.py near your settings.py
  • move all sensitive stuff to settings_local.py
  • add following code to import sensitive settings to settings.py:

    try:
        from .settings_local import *  # noqa
    except ImportError:
        pass
    
  • add settings_local.py to .gitignore so git would exclude it from commits

  • remove sensitive data from GitHub following this guide
  • create settings_local.py on pythonanywhere and your local machine manually or with some script

Leave a comment