How to maintain django different settings both on server and Github

This question already has an answer here:

  • Using Git to keep different versions of a file locally vs. in the master repository

    2 answers

  • How should I organize multiple related applications using git?
  • Unable to push to Git Repository after adding a branch
  • Set up new project repository on windows LAN envirnment
  • How to get the current revision number into a file after export?
  • Development and testing branch in @nvie's Git branching model?
  • Migrating from Mercurial to Subversion
  • Sonar does not download plugins
  • To make the change effective both in master and in branch
  • One Solution collect form web for “How to maintain django different settings both on server and Github”

    What I’d suggest is to remove from your any settings that depend on where it is deployed. Put those settings into environment variables. For example:

    STATIC_ROOT = os.environ.get('STATIC_ROOT')

    then you need to set those environment variables before running the webserver.

    On local:

    STATIC_ROOT=`pwd`/static python runserver

    On production depends on how you deploy, consult the documentation.

    This principle of config into environment variables is exposed in the Twelve Factor App :

    Git Baby is a git and github fan, let's start git clone.