Settings Error

After I created the tables in the database and pushed to heroku, I get a settings error rather than the 500 error. In heroku logs, I get "Import Error: Could not import settings ' microblog .settings/ (Is this a sys.path?): NO module named settings.

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

Answers

hmm. Check that all of your project directories have a __init__.py file in them.

Hello I included the imports in both files (.base and .local) and it worked
camilosanchez on
Another thing. I'm running the server but I can't reach the server at "127.0.0.1:8888". So, it's not reading the files in the "settings" folder.
jwhines on
I have an __init__.py in the "/microblog/microblog" and in "settings" folder. However, the file in the "settings" folder only has the imports from .base and .local. Should both have the imports?
jwhines on

Can you put the project on Github so I can look at the files & structure?

You can find the project at https://github.com/jwhines/microblog
jwhines on
I can. I just copied the imports from the "settings/__init__.py" to the "microblog/__init__.py" and got passed the error. Now I'm getting the 500 error.
jwhines on

OK, pulled your repo, set it to DEBUG = True, pushed everything up to Heroku without the changes to microblog/__init__.py and it works. So, checking your requirements and settings and I'm pretty sure you got bit by the ALLOWED_HOSTS bug in Django 1.5.x.

In your microblog/settings/base.py, there's a setting named ALLOWED_HOSTS. It's an empty list by default. You need to put your Heroku url into it as a string (e.g. ALLOWED_HOSTS = ['falling-river-3252.herokuapp.com']) and that should stop the 500 from being thrown.

I didn't come across any issues relating to settings.

OK so yeah this is prob because I'm using the wrong version of django, everything else worked and the local is fine so I guess I'll move on to lesson 2 and make sure I install the right django version
BangPotential on
OK, that didn't turn out the way I wanted, I'm having the same exact problem and dong to ALLOWED_HOSTS bit didn't solve it. I syncdb'd locally git master pushed and the heroku syncdb came back with the same error
BangPotential on
(blog-venv)vagrant@precise64:/vagrant/projects/microblog$ heroku run python manage.py syncdb Running `python manage.py syncdb` attached to terminal... up, run.1372 Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 263, in fetch_command app_name = get_commands()[subcommand] File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 109, in get_commands apps = settings.INSTALLED_APPS File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'microblog.settings' (Is it on sys.path?): No module named settings
BangPotential on
Thanks! Got it working with the above instructions. Why is DEBUG set to True in the base.py when it's set to True in local.py. The video changed the DEBUG in base.py to False.
jwhines on

Yes, your DEBUG setting should be False in your settings/base.py. I set it to True for debugging purposes. Once you have the domain set correctly, turn DEBUG back to False.

Having the settings imports in microblog/__init__.py makes no sense and is not the solution to this problem.