-
-
Notifications
You must be signed in to change notification settings - Fork 319
Open
Description
Description
When running the constance management command with remove_stale_keys, the Django setting CONSTANCE_DATABASE_PREFIX is not honored. That means that using the DatabaseBackend with a non-empty string prefix will result in all keys being dropped from the database. If CONSTANCE_DATABASE_CACHE_BACKEND is set to False, or if caching is enabled but the TTL of any item has expired, then the next usage of any configuration item will have its default value.
Steps to Reproduce
- In a Django project with
django-constance>2.6, use a non-empty string prefix:# your/project/settings.py, where DJANGO_SETTINGS_MODULE=your.project.settings CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" CONSTANCE_DATABASE_CACHE_BACKEND = None CONSTANCE_DATABASE_PREFIX = "constance:" CONSTANCE_CONFIG = { "MY_FEATURE_ENABLED": ( True, "Whether my feature is enabled", ) }
- In a terminal, start your database and cache
- Start the dev server with
python manage.py runserver - Navigate to the Django Admin Constance page and update
MY_FEATURE_ENABLEDtoFalse, being sure to save - In a terminal, run the management command:
$ python manage.py constance remove_stale_keys The following record will be deleted: constance:MY_FEATURE_ENABLED {"__type__": "default", "__value__": false} - Refresh the Django Admin Constance page. You'll see the default value of
Trueinstead of the value previously set in step 4
Metadata
Metadata
Assignees
Labels
No labels