#!/usr/bin/env python
# coding: utf-8
import os, sys, subprocess, time, re, ast
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webapi.server.project.settings")
import django
django.setup()
from django.apps import apps
try:
cchilders: ./write_creation_tests.py
Traceback (most recent call last):
File "./write_creation_tests.py", line 17, in <module>
django.setup()
AttributeError: 'module' object has no attribute 'setup
if I remove the setup attempt I can't import apps:
#!/usr/bin/env python
# coding: utf-8
import os, sys, subprocess, time, re, ast
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webapi.server.project.settings")
from django.apps import apps
try:
cchilders: ./write_creation_tests.py
Traceback (most recent call last):
File "./write_creation_tests.py", line 19, in <module>
from django.apps import apps
ImportError: No module named apps
in manage.py:
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webapi.server.project.settings")
thus my os.environ
setting matches the format in another project. I run this script the same way in the other django project and it works, but not in my webapi. These projects are on pythonpath. How can I setup django? Thank you