[Django]-DJANGO_SETTINGS_MODULE is undefined?

4👍

Add this to the top, it looks like the path to your settings file is not in your system path:

path = '/path/to/mysite'
if path not in sys.path:
   sys.path.append(path)

0👍

if you are using django 1.6 +
the below code should do it for you

import os
import sys
sys.path.append('/path/to/your/project/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project.settings")
from django.contrib import auth
from django.conf import settings
from django.contrib.auth.models import User

Leave a comment