Opened 9 years ago

Last modified 9 years ago

#24815 closed New feature

Custom settings for database alias — at Version 1

Reported by: Miguel Angel Velazco Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Miguel Angel Velazco)

It could be excelet to be able to set custom settings depending the database alias. An excelent example could be the management of the media files.

Maybe to do something like this:

settings.py

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DATABASES = {
   'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'uno.sqlite3'),
    },
    'another': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'uno.sqlite3'),
        'ADDITIONAL_SETTINGS': {
            'MEDIA_ROOT': os.path.join(BASE_DIR, "custom_media"),
        }
    },
}

Is important to say that this custom settings should be applied when a database router switch databases.

Change History (1)

comment:1 by Miguel Angel Velazco, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top