Django stores all the settings including the security hash, Database credentials and more in It offers easy to manage functions but creates difficulty in keeping the database credentials secret, using system dependent variables requires to edit the settings on every time the application is to be moved to new system, and is not a file you can ignore in version control so changing it will break the version control.

The solution is simple, move these system variables to local settings file and create one of these local settings for each system the application is to be run, this helps to edit only the required settings and the local file can be exempted from the version control.

Django does not offer this function in the box, but is straight forward to implement:

  1. Add to your project, in the same directory where is.
  2. Import the to project.

    To import add this to the end of

        from local_settings import *
    except ImportError:

    The try/except block informs Python to ignores in case it dose not exist.

  3. Inform the version control to ignore the

Including the over rides the settings defined in the and adds additional settings if any in the local settings.

Since is not in version control any changes won’t effect the version

Note : Make sure to document the settings in or create local_settings.sample as clone of local settings & add the sample to version control for record.