I am newbee in Django.I finished the Django Tutorial once from the official djangoproject site.Not saying I know everything now, but everything worked perfectly for me till I was referring that website.
I started referring to the Practical Django projects book and somewhere in my models I tried to import :
from django.contrib.auth.models import User
gives me an import error :
ImportError Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined
`
What is really going on here ? I have been successfully importing all the packages till now then why this sudden error ?
How are you running the code that gives you the error? If you are importing the
models.pyin the shell, use the Django shell commandIf you are trying the import in another script, you have to set the environment variable
DJANGO_SETTINGS_MODULEmanually.This requires
myprojectto be in your python path.See this similar Stack Overflow question for futher discussion.