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
- [Django]-Django – Ordered Table
- [Django]-Django – Trouble adding User to User Group with custom User Model
- [Django]-Implement get_serializer in generic list view (generics.ListCreateAPIView) in Django REST Framework
- [Django]-Django-translation: How to translate languages
Source:stackexchange.com