﻿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
19167	When running tests, Django accesses the database referred to in settings	Daniele Procida	nobody	"https://docs.djangoproject.com/en/dev/topics/testing/#the-test-database says:

{{{
Tests that require a database (namely, model tests) will not use your ""real"" (production) database. Separate, blank databases are created for the tests.
}}}

There seem to be circumstances in which Django '''will''' access the real database that is referred to in settings. 

Say I have a model called `Entity`.

I find I can't directly access the real database's `Entity` objects in tests, and in most of the application code, as expected, Django doesn't find anything in `Entity.objects.all()`. This is what the documentation tells me to expect.

However, in other parts of the code, `Entity.objects.all()` '''does''' return the Entity objects from the real database, which surprised me. The real database is accessed '''before''' Django gets to ""Creating test database for alias 'default'...""

If the real database is removed, then things behave as I would expect.

If it is to be expected that Django code when running tests will sometimes access the real database, then the documents need to explain when or how this will happen - but I don't think it should happen."	Uncategorized	closed	Documentation	1.4	Normal	fixed			Accepted	1	0	0	0	0	0
