﻿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
16873	removal of deprecated settings.DATABASE code causes shell scripts to raise  ImproperlyConfigured	Preston Holmes	Preston Holmes	"There is a pattern out there for shell scripts that interact with django that simply call:

{{{
from django.conf import settings; settings.configure()
import django modules here
}}}

loading some modules cause an ImproperlyConfigured exception to be raise in trunk@16848 where such an exception was not raised in 1.3

This is due to the removal of code related to adapting settings.DATABASES for the case of the deprecated single database setting

This change can be seen in this commit:

https://github.com/django/django/commit/4f306a4c27c8537ca9cd966cea1c0de84aafda9e#django/db/__init__.py

The prior code would create a default set of values for settings.DATABASES[DEFAULT_DB_ALIAS]

This no longer occurs, which triggers the raising of ImproperlyConfigured

There are two ways around this:

one is to fully specify the setting with:

{{{
from django.conf import settings; settings.configure(
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': '/tmp/dev'
        }
    })

}}}

The other is to use the setup_environ pattern:

{{{
from django.core.management import setup_environ
from dummyproj import settings
setup_environ(settings)
}}}

While none of these patterns are documented officially in Django's docs, there is widespread use of something like this in cron jobs shell scripts etc.  This perhaps could warrant a note in the release notes alongside the part about what is being deprecated?"	Bug	closed	Database layer (models, ORM)	dev	Release blocker	fixed			Accepted	1	0	0	0	0	0
