Ticket 25504 - multiple databases with no default

I made a comment on that issue, but there may be more responses here. Basically, the Django documentation seems to say that the “default” database is both required and not required, depending on where you look. Seems like at least one of the places in the docs should be changed.

Any thoughts or suggestions?

The linked multiple databases docs say:

Django requires that a default database entry be defined, but the parameters dictionary can be left blank if it will not be used.

Whilst the DATABASES docs say:

The DATABASES setting must configure a default database; any number of additional databases may also be specified.

I don’t see a huge conflict: the multiple databases docs clarify that default can be there but empty.

Perhaps the DATABASES phrase “must configure a default database” could be changed to “must include a default database” ?

Thanks, @adamchainz. I think the phrase “must configure a default database” could be understood to mean that it has to have the actual host, name, … information set up. If the only thing that phrase means is that there must be a “default” key in the DATABASES setting, but its value can be an empty dict (like in the multiple databases example), I would suggest saying something like “The DATABASES setting must contain a “default” key, although its value can be an empty dict” (possibly with a link to the multiple-db documentation that gives an example of that).

If that’s the case, that it’s just the “default” key that’s required in the setting, I wonder if it would make sense to look into whether that requirement could be removed - maybe it wouldn’t be a huge change from “the default key must be there even if it only has an empty dict for its value” to “we can just assume the empty dict value if the default key isn’t there”.

1 Like

I’ve been trying to confirm this conclusion, so I have created a project with a minimal app (with empty models), defined a simple test case with a no-op test, and configured DATABASES to be:

 DATABASES = {
    "default": {},
    "other": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": BASE_DIR / "other.sqlite3",
    },
}

The tearDown fails as reported in ticket #25504 with:

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

@adamchainz what do you mean exactly with “can be there but empty”?