1

According to Django Docs we can define empty django settings like this {} but it still raises error .

ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

"""
Django settings for impactFund project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 's^(gvcg1_!!!8wnpikp[hj4+%ypay1$zsf54=j6o3cuuxigjxiscqno'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'Ken_app',
    'app',

    'captcha',
    'django.contrib.sites',
    'treebeard',
    'djangocms_text_ckeditor',    
    'cms',  # django CMS itself
    'mptt',  # utilities for implementing a modified pre-order traversal tree
    'menus',  # helper for model independent hierarchical website navigation
    #'south',  # intelligent schema and data migrations
    'sekizai',  # for javascript and css management
    'djangocms_admin_style',  # for the admin skin. You **must** add 'djangocms_admin_style' in the list **before** 'django.contrib.admin'.
     # to enable messages framework (see :ref:`Enable messages <enable-messages>`)

)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.gzip.GZipMiddleware',

    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',    

)

ROOT_URLCONF = 'Fundimpact.urls'

WSGI_APPLICATION = 'Fundimpact.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases


DATABASES = {

    'default': {  # Leave this blank, we do not want a 'default' database defined.
        'ENGINE': '', 
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    },


    'prisen_db':{
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'prisen_db',                      
        'USER': 'prmken_user',                      
        'HOST': '59.77.142', 
        'PASSWORD':'PmN7&#5B',    

    },
    'prism_db':{
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'prism_db',                      
        'USER': 'prism_user',                      
        'HOST': '59.77.142', 
        'PASSWORD':'PC$MN',    

    }
 }   



DATABASE_ROUTERS = ['app.dbRouter.AppDBRouter', 'Ken_app.dbRouter.Ken_appDBRouter']

TEMPLATES = [
   {
       'BACKEND': 'django.template.backends.django.DjangoTemplates',
       'DIRS': [
       os.path.join(PROJECT_PATH, 'Ken_app','template'),
       os.path.join(PROJECT_PATH, 'app','templates'),
                ],
       'APP_DIRS': True,
       'OPTIONS': {
           'context_processors': [
               'django.template.context_processors.debug',
               'django.template.context_processors.request',
               'django.contrib.auth.context_processors.auth',
               'django.contrib.messages.context_processors.messages',
               'django.core.context_processors.i18n',              
               'django.core.context_processors.static',
               'sekizai.context_processors.sekizai',
           ],
       },
   },
]


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

#FILE_CHARSET = ""

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)



CKEDITOR_SETTINGS = {
    'language': '{{ language }}',
    'toolbar': 'CMS',
    'skin': 'moono',
}


CMS_PLACEHOLDER_CONF = {
    'content': {
        'plugins': ['TextPlugin', 'LinkPlugin'],
        'default_plugins':[
            {
                'plugin_type':'TextPlugin',
                'values':{
                    'body':'<p>Great websites : %(_tag_child_1)s and %(_tag_child_2)s</p>'
                },
                'children':[
                    {
                        'plugin_type':'LinkPlugin',
                        'values':{
                            'name':'django',
                            'url':'https://www.djangoproject.com/'
                        },
                    },
                    {
                        'plugin_type':'LinkPlugin',
                        'values':{
                            'name':'django-cms',
                            'url':'https://www.django-cms.org'
                        },
                    },
                ]
            },
        ]
    }
}

these are my routers for both apps which are in individual app folders

import random

class Ken_appDBRouter(object):
    """
    A router to control app db operations
    """
    def db_for_read(self, model, **hints):
        "Point all operations on app models to 'kenya"
        from django.conf import settings
        if not settings.DATABASES.has_key('Ken_app'):
            return None
        if model._meta.app_label == 'Ken_app':
            return 'prisen_db'
        return None

    def db_for_write(self, model, **hints):
        "Point all operations on app1 models to 'kenya'"
        from django.conf import settings
        if not settings.DATABASES.has_key('Ken_app'):
            return None
        if model._meta.app_label == 'Ken_app':
            return 'prisen_db'
        return None

    def allow_relation(self, obj1, obj2, **hints):
        "Allow any relation if a model in app is involved"
        from django.conf import settings
        if not settings.DATABASES.has_key('Ken_app'):
            return None
        if obj1._meta.app_label == 'Ken_app' or obj2._meta.app_label == 'Ken_app':
            return True
        return None

    def allow_syncdb(self, db, model):
        "Make sure the Ken_app app only appears on the 'kenya' db"
        from django.conf import settings
        if not settings.DATABASES.has_key('Ken_app'):
            return None
        if db == 'prisen_db':
            return model._meta.app_label == 'Ken_app'
        elif model._meta.app_label == 'Ken_app':
            return False
        return None


import random

class AppDBRouter(object):
    """
    A router to control app db operations
    """
    def db_for_read(self, model, **hints):
        "Point all operations on app models to 'app'"
        from django.conf import settings
        if not settings.DATABASES.has_key('app'):
            return None
        if model._meta.app_label == 'app':
            return 'prism_db'
        return None

    def db_for_write(self, model, **hints):
        "Point all operations on app1 models to 'india'"
        from django.conf import settings
        if not settings.DATABASES.has_key('app'):
            return None
        if model._meta.app_label == 'app':
            return 'prism_db'
        return None

    def allow_relation(self, obj1, obj2, **hints):
        "Allow any relation if a model in app is involved"
        from django.conf import settings
        if not settings.DATABASES.has_key('app'):
            return None
        if obj1._meta.app_label == 'app' or obj2._meta.app_label == 'app':
            return True
        return None

    def allow_syncdb(self, db, model):
        "Make sure the app app only appears on the 'app' db"
        from django.conf import settings
        if not settings.DATABASES.has_key('app'):
            return None
        if db == 'prism_db':
            return model._meta.app_label == 'app'
        elif model._meta.app_label == 'app':
            return False
        return None

here is the trace back. enter image description here

7
  • Care to tell us what the error is?.. Commented Sep 14, 2016 at 6:49
  • And we're supposed to magically find out what the error is with our psychic powers. But I need a headache first, thank you. Commented Sep 14, 2016 at 7:10
  • ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. Commented Sep 14, 2016 at 7:59
  • This error happens when you use the default (empty) backend, not when you define it. Please provide the full traceback and the relevant code. Commented Sep 14, 2016 at 9:02
  • But when I use default : {} raises same error , I can't remove default as it has to be there even when not used . Commented Sep 14, 2016 at 9:18

2 Answers 2

2

Your default database is not empty:

'default': {  # Leave this blank, we do not want a 'default' database defined.
    'ENGINE': '', 
    'NAME': '',
    'USER': '',
    'PASSWORD': '',
    'HOST': '',
    'PORT': '',
},

Change it to

'default': {},

Additionally, you are missing routing for auth. Change one of your routers to accept also auth or add a third router for it.

Sign up to request clarification or add additional context in comments.

16 Comments

The error is ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
I'm not too familiar with db routing, but it seems you are missing routing for the auth app. For auth both of your routers seem to return None, in which case Django reverts back to default.
I guess you found it in Docs where routers were defined for same application where auth tables will go to auth_db and rest to replicas(db) but in my case I have 2 different apps and 2 different databases in 1 project .
It doesn't matter. auth is an app the same as your own two apps, and it also needs a database. So you need to modify one of your routers to accept also auth or add a third router for it.
Do you mean like auth is a predefined class which routes all authentication related tables , cause this way I need to have 4 routers 2 for non auth related , 2 for auth related
|
0

To surpass the internal checking mechanism :

# We wont use Django databases
DATABASES = {
    'default': {
        'ENGINE': '',
    }
}

# Override TestRunner methods
TEST_RUNNER = 'tests.NoSQLTestRunner'

You will make another tests.py file and save the things below

from django.test.simple import DjangoTestSuiteRunner
from django.test import TestCase

class NoSQLTestRunner(DjangoTestSuiteRunner):
    def setup_databases(self):
        pass
    def teardown_databases(self, *args):
        pass

class NoSQLTestCase(TestCase):
    def _fixture_setup(self):
        pass
    def _fixture_teardown(self):
        pass

2 Comments

Since I have multiple apps , where do i need to add this file ?
this file will be in the same folder as the settings one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.