heroku run gives error about settings

Hello, I could successfully run this: python manage.py syncdb, but when it was time to run heroku, with heroku run python manage.py syncdb I got this error: Could not import settings 'microblog.settings' (Is it on sys.path?): No module named settings

Sorry You must be a logged in, registered user to answer a question.

Answers

I had the same issue--my solution was to add the settings directory to git with git add settings/. For some reason the entire settings directory was not being tracked. We only want the avoid tracking the local settings file.

Of course, make sure your .gitignore excludes settings/local.py first...

I'm not familiar with git, and I had forgotten to add the new files in the settings folder. Anyway I did that, did the push heroku master, and now I got this error:

OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I faced the same error & I simply removed local.py from my git repo using "git rm --cached microblog/settings/local.py". I'd also forgotten to add it to my .gitignore. everything works fine now
Mohsen Mansouryar on
It's not used on Heroku because it shouldn't be included in the Git repo push to Heroku.
kennethlove (Staff) on
See this question: http://gettingstartedwithdjango.com/questions/1/keeping-localpy-local/ for an explanation on why he's not tracking local.py with Git.
John Brewer on
Yup, that's it. I guess we're not supposed to track local.py with Git. So when you deploy to Heroku it'll throw the ImportError that we're passing through in __init__.py. As mentioned in another question be sure to set ALLOWED_HOSTS to your Heroku site to get this to work with newer versions of Django.
John Brewer on
I too have this error, I think it's because our local settings to use pyscopg2 are running rather than the dj_database_url config Heroku needs. What I don't understand myself is where in the videos he makes it so that the local.py settings file is not used on Heroku. Seems like it's imported by __init__.py. Maybe I missed something?
John Brewer on
I think it all has to do with the creation of the database in the first place? Like in the question about the "vagrant" role in another thread.
eduardovs on