django - How can I set environment variable in DJANGO_SETTINGS_MODULE -



django - How can I set environment variable in DJANGO_SETTINGS_MODULE -

from django.contrib.auth.models import user

if give above coding in terminal, throws below error. using ubuntu. how can set environment variable? using python 2.7.6 version.

file "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup raise importerror("settings cannot imported, because environment variable %s undefined." % environment_variable) importerror: settings cannot imported, because environment variable django_settings_module undefined.

i 1 time had this, in order database-related testing work in project did:

import os if not 'django_settings_module' in os.environ or os.environ['django_settings_module'] != '<myproject>.settings': os.environ['django_settings_module'] = '<myproject>.settings' django.contrib.auth.models import user

django

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -