Sreekar Mouli
Sreekar Mouli

Reputation: 1432

After deploying to heroku

I have a webapp which is not yet complete but I recently deployed it to heroku. It uses:

Now, I have deployed deploy-heroku branch of my project to master of heroku.

The only difference between my project's master branch and deploy-heroku branch is that I have made additional changes in settings.py (adding prostgre sql settings and all) in the deploy-heroku branch.

I want to add more features to my webapp so should I work on master and later copy-paste those changes to deploy-heroku. This seems redundant !! Is there any other better way to do this?

Upvotes: 0

Views: 537

Answers (2)

Antoine Chauvin
Antoine Chauvin

Reputation: 66

You could just let Heroku automatic deploy on master and use a ".env" file with Django-environ (https://github.com/joke2k/django-environ) to change your settings.py. You should be able to create a local Django setting and a Heroku prod setting.

Example :

.env :

DEBUG=on
SECRET_KEY=your-secret-key
DATABASE_URL=psql://urser:[email protected]:8458/database
SQLITE_URL=sqlite:///my-local-sqlite.db

setting.py:

 import environ
    env = environ.Env(
        # set casting, default value
        DEBUG=(bool, False)
    )
    # reading .env file
    environ.Env.read_env()

    # False if not in os.environ
    DEBUG = env('DEBUG')

    # Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
    SECRET_KEY = env('SECRET_KEY')

    # Parse database connection url strings like psql://user:[email protected]:8458/db
DATABASES = {
    # read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
    'default': env.db(),
    # read os.environ['SQLITE_URL']
    'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')
}

Don't forget to add the .env file to your .gitignore and to update your Heroku environment variables in your app -> settings -> Reveal config vars

Upvotes: 1

Damian Busz
Damian Busz

Reputation: 1848

You can merge branches.

Here is a good explanation of how it works

Upvotes: 0

Related Questions