Dynamic Settings
Waldur keeps the settings administrators change at runtime in its own settings store, waldur_core.configuration: changes made in the UI, the API or the Django admin take effect without restarting the application. A setting that was never changed has no stored row and reads as its default. The store replaced django-constance and keeps its setting definitions, so the names below still carry the CONSTANCE_ prefix.
Code reads a setting through from waldur_core.configuration import config (config.SITE_NAME) and tests change one with waldur_core.configuration.testing.override_config.
Configuration Structure
Settings are defined in src/waldur_core/server/constance_settings.py within the CONSTANCE_CONFIG dictionary.
Each setting is a 3-element tuple of basic metadata, and a separate CONSTANCE_CONFIG_CHOICES dictionary holds enum options:
1. Basic Configuration (CONSTANCE_CONFIG)
1 2 3 4 5 | |
- Default Value: The initial value (and type if field type is not specified).
- Description: A human-readable description (used for tooltips and help text).
- Field Type: A string identifying the UI component and backend validator to use.
2. Enum Choices (CONSTANCE_CONFIG_CHOICES)
To provide options for choice_field or multiple_choice_field, add an entry to CONSTANCE_CONFIG_CHOICES:
1 2 3 4 5 6 | |
Custom Field Types
Waldur implements several custom field types to enhance the configuration experience:
| Type | Description | Component | Options Required? |
|---|---|---|---|
choice_field |
Single selection from a predefined list. | Select | Yes |
multiple_choice_field |
Multiple selection from a predefined list. | Multi-Select/Badges | Yes |
list_field |
Comma-separated list of strings. | Text/List | No |
dict_field |
JSON object (rendered with syntax highlighting). | Monaco Editor | No |
json_list_field |
List of JSON objects. | Monaco Editor | No |
html_field |
HTML content (with syntax highlighting). | Monaco Editor | No |
color_field |
Hex color code. | Color Picker | No |
image_field |
Image upload. | File Upload | No |
secret_field |
Sensitive data (masked in UI). | Password Input | No |
non_empty_field |
String that may be changed but not blanked out. | Text Input | No |
Practical Examples
1. Simple String Setting
By default, if only a default value and description are provided, it is treated as a string or boolean based on the default value's type.
1 | |
2. Single Choice Enum
Use choice_field and define choices in CONSTANCE_CONFIG_CHOICES.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
3. Multiple Choice Enum
Use multiple_choice_field for settings that accept a list of predefined options.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
4. Dictionary Configuration
Use dict_field for complex settings. In the UI, this will be rendered with a JSON editor.
1 2 3 4 5 | |
Where a value comes from
Each stored value records who wrote it last, in Setting.source, with updated_by and source_detail where they apply. A setting without a row reads as its default.
| Source | Written by |
|---|---|
api |
A person, through POST /api/override-settings/ or another endpoint that changes settings. updated_by holds them. |
admin |
A person, through the Django admin settings page. updated_by holds them. |
deployment |
The deployment's configuration: override_settings and init_matrix_settings, run by the Helm or Compose init job. source_detail holds the file or command. See below for what a deploy re-applies. |
cli |
An operator running a management command, such as set_constance_image, set_login_logo_language or import_structure. |
application |
Waldur itself, with no person acting, such as a refreshed eduTEAMS token or the telemetry deployment ID. |
migration |
A data migration, such as the copy out of django-constance in configuration.0002. |
The admin page and the API write only values that changed, so re-submitting a form does not claim the settings it did not change.
Settings the deployment manages
Besides the last writer, a setting records in managed_by what re-applies it on every deploy. A change made anywhere else lasts only until the next deploy.
override_settings FILE --lockis how the image'sinit-whitelabelingapplies its files on every start. It records the file inmanaged_byand locks the settings:POST /api/override-settings/answers 400 naming the file, and the Django admin shows them read-only. Re-submitting the current value is not an error.init_matrix_settingsrecords itself inmanaged_bybut does not lock:MATRIX_TOKENS_MANAGED_BYhands the Matrix settings between the deployment and the Setup wizard.- A file applied without
--lock, such as a one-off fix or input piped through/dev/stdin, writes its values and manages nothing. - A file applied with
--if-unset(languages.yaml) only seeds settings without a value; they are the administrators' to change.
A setting is handed back to administrators, keeping its value, when the file or command that manages it runs without it, or when its file is applied with --if-unset.
A file is recorded by its name, not its path, so any file of the same name acts for the deployed one: override_settings /tmp/whitelabeling.yaml --if-unset hands back everything the deployed whitelabeling.yaml manages, and the same file with --lock hands back what it does not set. Give one-off files a name of their own.
waldur override_settings --unlock SETTING only lifts the lock: while the file still holds the setting, the next deploy puts its value back and locks it again.
Settings Waldur changes itself while running (REMOTE_EDUTEAMS_REFRESH_TOKEN, TELEMETRY_DEPLOYMENT_ID) are only given a first value from a file, never re-applied or locked. A key in a file that is not a setting is reported and skipped.
GET /api/override-settings/sources/ lists the stored values with source, source_detail, locked and managed_by, for staff and support. waldur dump_settings --managed-only out.yaml dumps the settings a deploy re-applies, each under a comment naming its file or command.
override_constance_settings and dump_constance_settings are the former names of override_settings and dump_settings and still work, for deployments that call them.
Frontend Integration
Settings are automatically exported to the frontend via:
1. Metadata API: /api/metadata/settings/ provides the structured data.
2. Type Generation: The uv run waldur print_settings_description command generates SettingsDescription.ts in HomePort, allowing for typed access and generic form rendering.
Generic Rendering
The HomePort UI iterates through these settings and uses the type and options metadata to determine which component to render. The backend automatically merges CONSTANCE_CONFIG and CONSTANCE_CONFIG_CHOICES when exporting metadata.