Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku/Django: No module named dj_database_url

I'm trying to set up PostgresSQL for the first time on Django, running into this error when I try to do a syndb?

ImportError: Could not import settings 'testapp.settings' (Is it on sys.path?):

Also have this at the toop of my settings.py file, no idea if this is correct?

import dj_database_url
DATABASES = {'default': dj_database_url.config(default=os.environ.get('DATABASE_URL'))}
like image 877
zhuyxn Avatar asked Oct 02 '12 01:10

zhuyxn


2 Answers

You don't give a lot of information about exactly where you are trying to run your sync db? Locally? Or up on Heroku? My answer is going to assume that it's locally.

Basically, you need to have virtualenv install and pip. While working in your virtualenv (with it activated), you need to do a

 pip install dj-database-url

Then you need to do a:

 pip freeze > requirements.txt

Getting up and going on Python+Django+Heroku is not a really hard thing to do... but, there are quite a few steps. If you are fuzzy, I recommend the Heroku Django tutorial.

like image 100
David S Avatar answered Oct 29 '22 14:10

David S


You have to install dj-database-url.

Add it to your requirements.txt file.

like image 2
Kenneth Reitz Avatar answered Oct 29 '22 13:10

Kenneth Reitz