[Solved] 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'))}
Enquirer: zhuyxn

||

Solution #1:

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.

Respondent: David S

Solution #2:

You have to install dj-database-url.

Add it to your requirements.txt file.

Respondent: Kenneth Reitz

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.