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

  • SEARCH
  • Home
  • 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 7741035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:55:31+00:00 2026-06-01T08:55:31+00:00

My problem/issue We are working on an opensource project which we have hosted on

  • 0

My problem/issue

We are working on an opensource project which we have hosted on github. The project is written in Django and so we have our settings in a settings.py file. We have it open source not because we are too cheap for a subscription, but because we intentionally want it to be open source.

Anyways, we also want to run this code ourselves and so we have a site_settings.py which contains all sensitive data like the db password etc. Since we don’t want this on github for everyone to see, this is in the .gitignore file.

Normally we clone the repo and add this file locally and on the server, this way we all have our personal settings and sensitive data isn’t stored on git.

The problem is that we now want to run our code on Heroku, which doesn’t support the creation of files on the server, since heroku doesn’t work like a normal server ( it works with a distributed file system).

Of course I have thought about it myself, but I am not sure if this is the right approach. Please keep in mind that I am both new to Heroku and Git. The following is my current solution:

My current idea on how to fix this

There are two remotes:

  • origin == Github
  • heroku == Heroku

leaving out all the development and feature branches, we only have both the master branches (on Heroku and Github) to worry about.

My idea was to have the branches set up like this locally:

  • master -> remotes/origin/master
  • heroku -> remotes/heroku/master

On the master branch we put the site_settings.py in the .gitignore so git will ignore it when committing to Github, the same goes for all the dev branches etc. We collect all our changes in the master branch until we have a new release.

On the heroku branch we edited the .gitignore file to stop ignoring the site_settings.py, so it will be committed to Heroku once we push to the heroku branch.

Once we have a new release we switch to heroku branch and merge master into heroku like so:

git checkout heroku
git pull
git merge master

Once we have sorted out merge conflicts from the merge, we commit to Heroku and we have a new release up and running.. =D

My question

Is my idea acceptable to solve this (will it even work with the .gitignore like this?) and if not how do we solve this in the cleanest/best way possible? If you need more info don’t hesitate to ask 🙂

  • 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-01T08:55:32+00:00Added an answer on June 1, 2026 at 8:55 am

    For starters, storing your config in files is the wrong way to go about this, so don’t do it.

    From the 12factor app:

    An app’s config is everything that is likely to vary between deploys
    (staging, production, developer environments, etc). This includes:

    • Resource handles to the database, Memcached, and other backing
      services
    • Credentials to external services such as Amazon S3 or Twitter
    • Per-deploy values such as the canonical hostname for the deploy

    Apps
    sometimes store config as constants in the code. This is a violation
    of twelve-factor, which requires strict separation of config from
    code. Config varies substantially across deploys, code does not.

    A litmus test for whether an app has all config correctly factored out
    of the code is whether the codebase could be made open source at any
    moment, without compromising any credentials.

    Note that this definition of “config” does not include internal
    application config, such as config/routes.rb in Rails, or how code
    modules are connected in Spring. This type of config does not vary
    between deploys, and so is best done in the code.

    Another approach to config is the use of config files which are not
    checked into revision control, such as config/database.yml in Rails.
    This is a huge improvement over using constants which are checked into
    the code repo, but still has weaknesses: it’s easy to mistakenly check
    in a config file to the repo; there is a tendency for config files to
    be scattered about in different places and different formats, making
    it hard to see and manage all the config in one place. Further, these
    formats tend to be language- or framework-specific.

    The twelve-factor app stores config in environment variables (often
    shortened to env vars or env). Env vars are easy to change between
    deploys without changing any code; unlike config files, there is
    little chance of them being checked into the code repo accidentally;
    and unlike custom config files, or other config mechanisms such as
    Java System Properties, they are a language- and OS-agnostic standard.

    Another aspect of config management is grouping. Sometimes apps batch
    config into named groups (often called “environments”) named after
    specific deploys, such as the development, test, and production
    environments in Rails. This method does not scale cleanly: as more
    deploys of the app are created, new environment names are necessary,
    such as staging or qa. As the project grows further, developers may
    add their own special environments like joes-staging, resulting in a
    combinatorial explosion of config which makes managing deploys of the
    app very brittle.

    In a twelve-factor app, env vars are granular controls, each fully
    orthogonal to other env vars. They are never grouped together as
    “environments,” but instead are independently managed for each deploy.
    This is a model that scales up smoothly as the app naturally expands
    into more deploys over its lifetime.

    For Python, your config can be found in os.environ. For specific config, particularly the database you want to be using something like:

    import os
    import sys
    import urlparse
    
    # Register database schemes in URLs.
    urlparse.uses_netloc.append('postgres')
    urlparse.uses_netloc.append('mysql')
    
    try:
    
        # Check to make sure DATABASES is set in settings.py file.
        # If not default to {}
    
        if 'DATABASES' not in locals():
            DATABASES = {}
    
        if 'DATABASE_URL' in os.environ:
            url = urlparse.urlparse(os.environ['DATABASE_URL'])
    
            # Ensure default database exists.
            DATABASES['default'] = DATABASES.get('default', {})
    
            # Update with environment configuration.
            DATABASES['default'].update({
                'NAME': url.path[1:],
                'USER': url.username,
                'PASSWORD': url.password,
                'HOST': url.hostname,
                'PORT': url.port,
            })
            if url.scheme == 'postgres':
                DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
    
            if url.scheme == 'mysql':
                DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
    except Exception:
        print 'Unexpected error:', sys.exc_info()
    

    For more info on config vars, see here: https://devcenter.heroku.com/articles/config-vars

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

Sidebar

Related Questions

I'm currently working with django generic views and I have a problem I can't
I am working on an enormous project (the project) which is open-source, and I
I have been working on an open source project for awhile, http://gtkworkbook.sourceforge.net/ , and
I'm working on a project and have a problem that I believe can be
jquery-loadmask not working properly in IE8 I got a same problem. It was issue
I feel like the problem is extremely apparent. I'm working on an issue with
Issue is SOLVED: Problem is that it is a pre-compiled web page project and
I have a problem and I will try to explain the issue: I have
I'm working on a project that is using code from an OpenSource project. One
I'm currently working on a very small open source project for Maemo 5. (Namely

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.