Opened 7 years ago

Closed 7 years ago

#9714 closed (invalid)

Bug in --settings=mysettings

Reported by: fero Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords: management
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Hello I use Django-1.0
and I hit the following bug:

I have a with my default settings
and a for developing purposes in which I simply override the DATABASE_USER variable

If I do:
# python dbshell --settings=mysettings

I get the error:

Traceback (most recent call last):
  File "", line 11, in <module>
  File "/usr/local/sanet/django/core/management/", line 340, in execute_manager
  File "/usr/local/sanet/django/core/management/", line 295, in execute
  File "/usr/local/sanet/django/core/management/", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/sanet/django/core/management/", line 96, in execute
    output = self.handle(*args, **options)
  File "/usr/local/sanet/django/core/management/", line 178, in handle
    return self.handle_noargs(**options)
  File "/usr/local/sanet/django/core/management/commands/", line 10, in handle_noargs
  File "/usr/local/sanet/django/db/backends/dummy/", line 15, in complain
    raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet."
django.core.exceptions.ImproperlyConfigured: You haven't set the DATABASE_ENGINE setting yet.

I don't get the error if I do:

# DJANGO_SETTINGS_MODULE=mysettings python dbshell

Thank you for your work

Change History (3)

comment:1 Changed 7 years ago by ajs

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

As far as I know if you supply an alternate settings file with --setting it completley replaces the standard

comment:2 Changed 7 years ago by fero

I investigate more and exporting the DJANGO_SETTINGS_MODULE variable does not raise an exception,
but does not work either (it is a fake :) ) file does not work if it is

import settings

DATABASE_USER = 'postgres' # Superuser role for the db backend of choice

however I noticed that I succeed in make it working if the file is

import settings

DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_USER = 'postgres' # Superuser role for the db backend of choice

It is a bit weird. Now I have no time to find the bug in django code.
It is a really strange behaviour.

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

There is no Django bug here. All settings variables must be in the module-level namespace of the settings file. In other words, Django looks for the all-capitals variables in the file you say is the settings file. So in your first case, there is not settings called DATABASE_USER. There is something in the settings namespace -- settings.DATABASE_USER, but you have told Django that the mysettings file contains all the settings, so it is look for mysettings.DATABASE_USER, in effect.

That is why every example that shows importing from one settings file into another uses from settings import *.

Note: See TracTickets for help on using tickets.
Back to Top