from django.db import transaction
from django.contrib.auth.models import User
from flow.models import States, Types, Docs, Logs
if __name__ == '__main__':
with transaction.atomic():
models.Logs.objects.all().delete()
models.Docs.objects.all().delete()
models.States.objects.all().delete()
models.Types.objects.all().delete()
models.User.objects.all().delete()
user1.save()
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 38, in _setup
settings_module = os.environ[ENVIRONMENT_VARIABLE]
File "C:\Python34\lib\os.py", line 651, in __getitem__
raise KeyError(key) from None
KeyError: 'DJANGO_SETTINGS_MODULE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Daniel\Documents\Python\cresta\flow\test_data.py", line 7, in <module>
from django.contrib.auth.models import User
File "C:\Python34\lib\site-packages\django\contrib\auth\__init__.py", line 6, in <module>
from django.middleware.csrf import rotate_token
File "C:\Python34\lib\site-packages\django\middleware\csrf.py", line 14, in <module>
from django.utils.cache import patch_vary_headers
File "C:\Python34\lib\site-packages\django\utils\cache.py", line 26, in <module>
from django.core.cache import get_cache
File "C:\Python34\lib\site-packages\django\core\cache\__init__.py", line 69, in <module>
if DEFAULT_CACHE_ALIAS not in settings.CACHES:
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
self._setup(name)
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 47, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Thanks.