﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21027	"remember Tutorial users to invoke the shell by ""python manage.py shell"" before setting up the test environment"	anonymous	MaxV	"Working through the Tutorial 5 I stumbled across something I haven't expected. 
The tutorial suggest to setup the test environment, starting with:

{{{
>>> from django.test.utils import setup_test_environment
}}}

I used the standard python shell throughout the whole tutorial without any problems, but now I got the following message:

{{{
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/usr/lib/python2.7/site-packages/django/test/__init__.py"", line 5, in <module>
    from django.test.client import Client, RequestFactory
  File ""/usr/lib/python2.7/site-packages/django/test/client.py"", line 16, in <module>
    from django.contrib.auth import authenticate, login
  File ""/usr/lib/python2.7/site-packages/django/contrib/auth/__init__.py"", line 5, in <module>
    from django.middleware.csrf import rotate_token
  File ""/usr/lib/python2.7/site-packages/django/middleware/csrf.py"", line 16, in <module>
    from django.utils.cache import patch_vary_headers
  File ""/usr/lib/python2.7/site-packages/django/utils/cache.py"", line 26, in <module>
    from django.core.cache import get_cache
  File ""/usr/lib/python2.7/site-packages/django/core/cache/__init__.py"", line 70, in <module>
    if DEFAULT_CACHE_ALIAS not in settings.CACHES:
  File ""/usr/lib/python2.7/site-packages/django/conf/__init__.py"", line 53, in __getattr__
    self._setup(name)
  File ""/usr/lib/python2.7/site-packages/django/conf/__init__.py"", line 46, 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.
}}}

Of course, this ought to be happen, since I have bypassed manage.py and thus the DJANGO_SETTINGS_MODULE environment variable wasn't set. Anyway, for django newbies who didn't follow your advise in part 1 of the tutorial this might come as an surprise.

My suggestions:

1) Make the consequences of bypassing manage.py in part 1 of the tutorial more explicit (""XYZ won't work unless ..."")
2) Some newbies might appreciate at this early point of the tutorial a deeper explanation of the DJANGO_SETTINGS_MODULE environment variable.
3) Repeat the advise to invoke the shell through manage.py in ""Tutorial 5 / Test a view"", to help lazy newbies like me :-) 

Best regards
Stephan
"	Cleanup/optimization	closed	Documentation	1.5	Normal	fixed	"""Tutorial 1.5"" / ""Test a view"", afraid-to-commit"	st.sempert@… Daniele Procida MaxV	Accepted	0	0	0	0	1	0
