I’ve run Django servers on localhost before and have never run into this problem. I’m desperately trying to figure out what I’ve done wrong.
I’m using Django 1.4 with Python 2.7 on Ubuntu 12.04.
As far as I can tell I’ve configured everything correctly – I’m actually using another functional Django project I built as a go-by.
If I run the following command (or any recommended variation thereof) I receive an error.
django-admin.py runserver localhost:8000
Here is the error:
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
Can someone please enlighten me as to why this error is occurring, how to fix it and why it doesn’t happen with my other Django project?!?
I’ve found many posts regarding this problem just by doing some quick Google searches, but none of the suggested solutions have helped – nor do I truly understand them.
I’m pretty sure you’re supposed to run
from inside your project directory. It automatically loads your settings.py, etc.
From the Django docs: