Ali Rowing Ali Rowing Blur


Pushing Django Project to Heroku

I seem to keep googling the same commands over and over when I am publishing new versions of my django app to Heroku.

The main instructions are on Heroku Dev Center.

Here are some extra useful bits and pieces that I keep going back to. I am assuming you are in terminal, in your main application folder.


to find out what the database used in this app is called:

heroku pg:info

You should get an output starting with:


The database url you would need to use in various system calls (such as reset below) will be HEROKU_POSTGRESQL_{some_color}_URL.

to "reset" the database, and start everything fresh,

heroku pg:reset HEROKU_POSTGRESQL_{some_color}_URL

and remember to initialize the database:

heroku run python syncdb

Kick off the application locally:

Activate your Virtual Environment:

source VENV_NAME/bin/activate

(Remember, you can deactivate it using deactivate)

kick off a dev web server:

python runserver

(if you get 500 Server Error you might need to enable Debug mode in

Pushing Code Changes:

git commit -m 'Push Comment'

If you adding new files:

git add .

Static Files

I couldn't get my static files to upload to Heroku using the code snippet given in the Heroku insturctions (to be added to I have:

BASE_DIR_OLD = os.path.abspath(os.path.join(os.path.dirname(file), os.pardir))

STATICFILES_DIRS = ( #os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR_OLD, 'ngr/static' ), )

where ngr is the particular app.

instead of:

BASE_DIR = os.path.dirname(os.path.abspath(file))

STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )

I couldnt figure out why I ndeeded to do that.

Posted on 22 Dec 2013, 9:31 p.m.

back to Blog