Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:58:57+00:00 2026-06-02T20:58:57+00:00

Question Is my approach to multiple Django settings.py files below reasonable (transparent, safe, etc.)?

  • 0

Question

Is my approach to multiple Django settings.py files below reasonable (transparent, safe, etc.)?

My Approach

I have a settings.py and a settings_local.py. settings.py is under version control and a settings_local.py is NOT under version control. At the end of settings.py it tries to import settings_local.py if it’s available.

My theory to this approach is that I can leave my default / safe settings under settings.py and simply push to production to deploy. On deploy, settings_local.py won’t be present and its local-only settings are not used. However, when working locally settings_local.py is present and its local-only settings are used.

settings.py

DEBUG = False
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
)
# other settings...

try:
    from settings_local import *
except ImportError:
   pass

settings_local.py

from settings import *

DEBUG = True
MIDDLEWARE_CLASSES += (
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)
# other settings...

My concern about this approach is that they both import the other. I don’t think this qualifies as a circular import but as an indicator that under different circumstances one would consider combining these files.

The reason settings_local.py imports settings.py is so I can add to already defined variables while observing DRY principles e.g. add a new entry to MIDDLEWARE_CLASSES without completely redefining it.

Thanks!


Solution

Ultimately, I abandoned the above outlined approach. It was an interesting and informative process for me to try solving this problem, however, my amalgamated approach just has too many drawbacks.

For folks finding this in the future, the most appropriate approach is likely one of the solutions as outlined in the wiki page on this topic as kindly pointed out by @DrTyrsa and @Mark Lavin, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:58:58+00:00Added an answer on June 2, 2026 at 8:58 pm

    While this is a common approach it is not a good approach. I have used this type of configuration in the past and since abandoned it. The problem comes when you have multiple developers working together or when you are deploying to multiple environments (i.e. staging and production). You have the choice of either

    1. Make settings.py the production settings. Then each developer must override settings to setup their local environment (DB settings, DEBUG=True, adding debug_toolbar, etc). Since this is not in source control it is repeated work and leads to “it works on my machine” kinds of problems.
    2. Make settings.py the development settings. Now you have meaningful pieces of your production configuration in local_settings.py which is not in source control. This makes deployment messy. Obviously you don’t want to put sensitive information in the source control.

    Adding a staging environment just makes this worse. I much prefer the Simple Package Organization for Environments described in the SplitSettings wiki.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question, is this the correct approach to make a Generic Singleton?
Note: This is an alternate planned approach to this question: Multiple column articles in
[UPDATE] Chosen approach is below, as a response to this question Hi, I' ve
I know this question has been asked multiple number of times and i have
I have a quick question in regards to the approach to displaying products on
I have a C program with multiple files, so I have, for example, stuff.c
just had a general question about how to approach a certain problem I'm facing.
The very act of asking this question suggests that my approach to this problem
I find this question a little tricky. Maybe someone knows an approach to answer
What are the technical questions I simply must have answers for before I approach

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.