Django Tutorial Error: Setting up the test client
Question: I'm on part 5 of the Django Tutorial and I've hit a snag. I'm trying to setup
the test client with the following commands in the python shell:

    
    
    from django.test.utils import setup_test_environment
    setup_test_environment()
    

I get the following error

    
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/mohitgupta/.virtualenvs/Django/lib/python2.7/site-packages/django/test/utils.py", line 104, in setup_test_environment
        mail._original_email_backend = settings.EMAIL_BACKEND
      File "/Users/mohitgupta/.virtualenvs/Django/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
        self._setup(name)
      File "/Users/mohitgupta/.virtualenvs/Django/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup
        % (desc, ENVIRONMENT_VARIABLE))
    django.core.exceptions.ImproperlyConfigured: Requested setting EMAIL_BACKEND, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
    

I've looked into defining the DJANGO_SETTINGS_MODULE with no real progress.
Just a note that I'm using PyCharm as an IDE but I don't use the internal
terminal they provide.

Any suggestions?


Answer: As mentioned in previous sections of the tutorial, to start a shell in Django
you should always do `./manage.py shell`, rather than starting Python
directly. That sets up the environment for you.

