Set Different Settings for Development in Django

djangoWhen you work in your local machine, most likely you need different settings. You can have this by adding a few lines of codes in your local settings.py. Put this code at the end of your settings.py

...
try:
    from settings_local import *
except ImportError:
    pass

and you create settings_local.py and overwrite some of the configurations and specify them according your local machine, don’t forget to set your version control (git, subversion, mercurial, etc) to ignore this file. For example while your production machine use mysql, you can use sqlite in your local machine:

settings.py

...
DATABASE_ENGINE = 'mysql' 
DATABASE_NAME = 'your-db-name'
DATABASE_USER = 'your-db-username'
DATABASE_PASSWORD = 'your-password'
...

settings_local.py

DATABASE_ENGINE = 'sqlite3' 
DATABASE_NAME = 'database.sqlite'

That’s it. Have fun.

Related posts:

  1. Relative Path for your Django Project
  2. Why We Need Version Control
  3. Django Tutorial – Simple Notes Application
  4. Web Development Tools in Linux

2 Tweets

6 Responses to “Set Different Settings for Development in Django”

  1. [...] This post was mentioned on Twitter by KomunitasWeb, Django Ireland. Django Ireland said: Set Different Settings for Development in Django | KomunitasWeb http://bit.ly/drToJg [...]

    Pingback by Tweets that mention Set Different Settings for Development in Django | KomunitasWeb -- Topsy.com — June 24, 2010 @ 6:15 am

  2. Heya¡­my very first comment on your site. ,I have been reading your blog for a while and thought I would completely pop in and drop a friendly note. . It is great stuff indeed. I also wanted to ask..is there a way to subscribe to your site via email?

    Comment by Clay Hudlin — June 24, 2010 @ 10:43 am

  3. You can follow my twitter or subscribe my feed. :)

    Comment by Gilang Chandrasa — June 25, 2010 @ 9:54 am

  4. I have been looking looking around for this kind of info. Will you publish some more in future? I’ll be grateful if you will.

    Comment by replica handbags — June 30, 2010 @ 9:12 pm

  5. New blog posting, Set Different Settings for Development in Django – http://tinyurl.com/375vpdx

    This comment was originally posted on Twitter

    Comment by komunitasweb — June 24, 2010 @ 5:22 am

  6. Set Different Settings for Development in Django | KomunitasWeb http://bit.ly/drToJg

    This comment was originally posted on Twitter

    Comment by DjangoIreland — June 24, 2010 @ 5:44 am

Additional comments powered by BackType