[Django]-Does django-constance admin supports database backend?

3👍

Yes, they do.

You need to manage dependencies, but you can just use next command to install:

pip install "django-constance[database]"

Also you need to add some additionl settings to your settings.py :

CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'

INSTALLED_APPS = (
    # other apps
    'constance.backends.database',
)

#optional - in case you want specify table prefix

CONSTANCE_DATABASE_PREFIX = 'constance:myproject:'

Then you need to apply migrations by running command python manage.py migrate database

For displaying settings inputs in admin you should specify them in your settings.py. There are various types of fields and you even can add your own types of fields using CONSTANCE_ADDITIONAL_FIELDS parameter.

CONSTANCE_CONFIG = {
    'THE_ANSWER': (42, 'Answer to the Ultimate Question of Life, '
                       'The Universe, and Everything'),
}

You can read more at documentation page.

👤s_mart

Leave a comment