• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Djblets 5.x
    2. Version 5.x
    3. Version 4.x
    4. Version 3.x
    5. Version 2.x
    6. Version 2.0
    7. Version 1.0
    8. Version 0.9
    9. Djblets Documentation
    10. Module and Class References
    11. djblets.siteconfig.models
  • Home
  • Guides
  • Avatar Services Guides
  • Writing Avatar Services
  • Extension Guides
  • Writing Extensions
  • Testing Extensions
  • Feature Checks Guides
  • Introduction to Feature Checks
  • Writing Features
  • Writing Feature Checkers
  • Testing with Feature Checks
  • Integration Guides
  • Supporting Integrations
  • Writing Integrations
  • Privacy Compliance Guides
  • Getting and Checking Consent
  • Working with Personally Identifiable Information
  • Service Integrations
  • reCAPTCHA Guides
  • Using reCAPTCHA
  • Registries Guides
  • Writing Registries
  • Web API Guides
  • Writing Web API Resources
  • Adding OAuth2 Support
  • Module and Class References
  • djblets
  • djblets.deprecation
  • djblets.auth.forms
  • djblets.auth.ratelimit
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.avatars.errors
  • djblets.avatars.forms
  • djblets.avatars.registry
  • djblets.avatars.services
  • djblets.avatars.services.base
  • djblets.avatars.services.fallback
  • djblets.avatars.services.file_upload
  • djblets.avatars.services.gravatar
  • djblets.avatars.services.url
  • djblets.avatars.settings
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.cache.synchronizer
  • djblets.conditions
  • djblets.conditions.choices
  • djblets.conditions.conditions
  • djblets.conditions.errors
  • djblets.conditions.operators
  • djblets.conditions.values
  • djblets.configforms.forms
  • djblets.configforms.mixins
  • djblets.configforms.pages
  • djblets.configforms.registry
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.fields.base64_field
  • djblets.db.fields.comma_separated_values_field
  • djblets.db.fields.counter_field
  • djblets.db.fields.json_field
  • djblets.db.fields.modification_timestamp_field
  • djblets.db.fields.relation_counter_field
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.query_catcher
  • djblets.db.query_comparator
  • djblets.db.validators
  • djblets.extensions.admin
  • djblets.extensions.errors
  • djblets.extensions.extension
  • djblets.extensions.forms
  • djblets.extensions.hooks
  • djblets.extensions.loaders
  • djblets.extensions.manager
  • djblets.extensions.middleware
  • djblets.extensions.models
  • djblets.extensions.packaging
  • djblets.extensions.resources
  • djblets.extensions.settings
  • djblets.extensions.signals
  • djblets.extensions.staticfiles
  • djblets.extensions.testing
  • djblets.extensions.testing.testcases
  • djblets.extensions.urls
  • djblets.extensions.views
  • djblets.extensions.templatetags.djblets_extensions
  • djblets.features
  • djblets.features.checkers
  • djblets.features.decorators
  • djblets.features.errors
  • djblets.features.feature
  • djblets.features.level
  • djblets.features.registry
  • djblets.features.testing
  • djblets.features.templatetags.features
  • djblets.forms.fields
  • djblets.forms.fieldsets
  • djblets.forms.forms
  • djblets.forms.forms.key_value_form
  • djblets.forms.widgets
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • djblets.http.middleware
  • djblets.http.responses
  • djblets.integrations.errors
  • djblets.integrations.forms
  • djblets.integrations.hooks
  • djblets.integrations.integration
  • djblets.integrations.manager
  • djblets.integrations.mixins
  • djblets.integrations.models
  • djblets.integrations.urls
  • djblets.integrations.views
  • djblets.log
  • djblets.log.middleware
  • djblets.log.siteconfig
  • djblets.log.urls
  • djblets.log.views
  • djblets.mail.dmarc
  • djblets.mail.message
  • djblets.mail.testing
  • djblets.mail.utils
  • djblets.markdown
  • djblets.markdown.extensions.escape_html
  • djblets.markdown.extensions.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.pipeline.compilers.es6
  • djblets.pipeline.compilers.less
  • djblets.pipeline.compilers.mixins
  • djblets.pipeline.compilers.rollup
  • djblets.pipeline.compilers.typescript
  • djblets.pipeline.settings
  • djblets.privacy.consent
  • djblets.privacy.consent.base
  • djblets.privacy.consent.common
  • djblets.privacy.consent.errors
  • djblets.privacy.consent.forms
  • djblets.privacy.consent.hooks
  • djblets.privacy.consent.registry
  • djblets.privacy.consent.tracker
  • djblets.privacy.models
  • djblets.privacy.pii
  • djblets.privacy.templatetags.djblets_privacy
  • djblets.recaptcha.mixins
  • djblets.recaptcha.siteconfig
  • djblets.recaptcha.templatetags.djblets_recaptcha
  • djblets.recaptcha.widgets
  • djblets.registries
  • djblets.registries.errors
  • djblets.registries.importer
  • djblets.registries.mixins
  • djblets.registries.registry
  • djblets.registries.signals
  • djblets.secrets
  • djblets.secrets.crypto
  • djblets.secrets.token_generators
  • djblets.secrets.token_generators.base
  • djblets.secrets.token_generators.legacy_sha1
  • djblets.secrets.token_generators.registry
  • djblets.secrets.token_generators.vendor_checksum
  • djblets.siteconfig
  • djblets.siteconfig.admin
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.signals
  • djblets.siteconfig.views
  • djblets.template.caches
  • djblets.template.context
  • djblets.template.loaders.conditional_cached
  • djblets.template.loaders.namespaced_app_dirs
  • djblets.testing.decorators
  • djblets.testing.testcases
  • djblets.testing.testrunners
  • djblets.urls.context_processors
  • djblets.urls.decorators
  • djblets.urls.patterns
  • djblets.urls.resolvers
  • djblets.urls.root
  • djblets.urls.staticfiles
  • djblets.util.compat.django.core.cache
  • djblets.util.compat.python.past
  • djblets.util.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.functional
  • djblets.util.html
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.json_utils
  • djblets.util.properties
  • djblets.util.serializers
  • djblets.util.symbols
  • djblets.util.templatetags.djblets_deco
  • djblets.util.templatetags.djblets_email
  • djblets.util.templatetags.djblets_forms
  • djblets.util.templatetags.djblets_images
  • djblets.util.templatetags.djblets_js
  • djblets.util.templatetags.djblets_utils
  • djblets.util.typing
  • djblets.util.views
  • djblets.views.generic.base
  • djblets.views.generic.etag
  • djblets.webapi.auth
  • djblets.webapi.auth.backends
  • djblets.webapi.auth.backends.api_tokens
  • djblets.webapi.auth.backends.base
  • djblets.webapi.auth.backends.basic
  • djblets.webapi.auth.backends.oauth2_tokens
  • djblets.webapi.auth.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.fields
  • djblets.webapi.managers
  • djblets.webapi.models
  • djblets.webapi.oauth2_scopes
  • djblets.webapi.resources
  • djblets.webapi.resources.base
  • djblets.webapi.resources.group
  • djblets.webapi.resources.registry
  • djblets.webapi.resources.root
  • djblets.webapi.resources.user
  • djblets.webapi.resources.mixins.api_tokens
  • djblets.webapi.resources.mixins.forms
  • djblets.webapi.resources.mixins.oauth2_tokens
  • djblets.webapi.resources.mixins.queries
  • djblets.webapi.responses
  • djblets.webapi.signals
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • General Index
  • Python Module Index
  • Release Notes
  • djblets.siteconfig.models¶

    Database models for storing site configuration.

    SiteConfigurationSettingsValue¶

    An alias for valid value types in site configuration settings.

    New in version 3.1.

    alias of Union[JSONDict, JSONDictImmutable, JSONList, JSONListImmutable, None, bool, float, int, str]

    SiteConfigurationSettings¶

    An alias for the container of settings in a site configuration.

    New in version 3.1.

    alias of Dict[str, Union[JSONDict, JSONDictImmutable, JSONList, JSONListImmutable, None, bool, float, int, str]]

    class SiteConfigSettingsWrapper(siteconfig: SiteConfiguration)[source]¶

    Bases: object

    Wraps the settings for a SiteConfiguration.

    This is used by the context processor for templates to wrap accessing settings data, properly returning defaults.

    __init__(siteconfig: SiteConfiguration) → None[source]¶

    Initialize the wrapper.

    Parameters:

    siteconfig (SiteConfiguration) – The site configuration to wrap.

    siteconfig: SiteConfiguration¶

    The site configuration associated with this wrapper.

    Type:

    SiteConfiguration

    __getattr__(name: str) → Optional[object][source]¶

    Return an attribute from the site configuration.

    If the attribute is not present in the site configuration’s settings, the registered default will be returned.

    Parameters:

    name (str) – The name of the attribute.

    Returns:

    The resulting value from the site configuration or the default.

    Return type:

    object

    __annotations__ = {'siteconfig': 'SiteConfiguration'}¶
    class SiteConfiguration(*args, **kwargs)[source]¶

    Bases: Model

    Stored version and settings data for a Django site.

    This stores dynamic settings for a site, along with version information, allowing the application to alter and apply/synchronize settings across threads, processes, and servers without restarting the server.

    Consumers should not create or fetch their own instance of this class through standard Django query functions. Instead, they should use SiteConfiguration.objects.get_current() instead. See the documentation for that method for details on how to safely look up and use site configuration.

    version[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    settings[source]¶

    A JSON dictionary field of settings stored for a site.

    classmethod add_global_defaults(defaults_dict: Dict[str, Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]]) → None[source]¶

    Add a dictionary of global defaults for settings.

    These defaults will be used when calling get() for any setting not stored. Defaults registered for a specific site configuration take precedent over global defaults.

    Parameters:

    default_dict (dict) – A dictionary of defaults, mapping siteconfig settings keys to JSON-serializable values.

    classmethod add_global_default(key: str, default_value: Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]) → None[source]¶

    Add a global default value for a settings key.

    The default will be used when calling get() for this key, if a value is not stored. Defaults registered for a specific site configuration take precedent over global defaults.

    Parameters:
    • key (str) – The settings key to set the default for.

    • default_value (object) – The value to set as the default.

    classmethod remove_global_default(key: str) → None[source]¶

    Remove a global default value for a settings key.

    Parameters:

    key (str) – The settings key to remove the default for.

    classmethod clear_global_defaults() → None[source]¶

    Clear all default values for this site configuration.

    This will clear only global defaults. This will not affect defaults registered on specific site configurations.

    classmethod get_global_defaults() → Dict[str, Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]][source]¶

    Return all global defaults for settings.

    Returns:

    A dictionary of all registered global defaults for settings.

    Return type:

    dict

    __init__(*args, **kwargs) → None[source]¶

    Initialize the site configuration.

    Parameters:
    • *args (tuple) – Positional arguments to pass to the parent constructor.

    • **kwargs (dict) – Keyword arguments to pass to the parent constructor.

    site[source]¶

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

    class Child(Model):
        parent = ForeignKey(Parent, related_name='children')
    

    Child.parent is a ForwardManyToOneDescriptor instance.

    get(key: str, default: Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str] = None) → Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str][source]¶

    Return the value for a setting.

    If the setting is not found, the default value will be returned. This is represented by the default parameter, if passed in, or a global default (from add_default()) if set.

    If no default is available, None will be returned.

    Parameters:
    • key (str) – The site configuration settings key.

    • default (object, optional) – The default value to return. If not provided, the registered default will be returned.

    Returns:

    The resulting value.

    Return type:

    object

    set(key: str, value: Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]) → None[source]¶

    Set a value for a setting.

    The setting will be stored locally until the model is saved, at which point it will be synchronized with other processes/servers.

    Parameters:
    • key (str) – The key for the setting.

    • value (object) – The JSON-serializable object to store.

    add_defaults(defaults_dict: Dict[str, Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]]) → None[source]¶

    Add a dictionary of defaults for settings.

    These defaults will be used when calling get() for any setting not stored. These will only be registered for this site configuration, and will not be registered for global defaults.

    Parameters:

    default_dict (dict) – A dictionary of defaults, mapping siteconfig settings keys to JSON-serializable values.

    add_default(key: str, default_value: Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]) → None[source]¶

    Add a default value for a settings key.

    The default will be used when calling get() for this key, if a value is not stored. This will only be registered for this site configuration, and will not be registered for global defaults.

    Parameters:
    • key (str) – The settings key to set the default for.

    • default_value (object) – The value to set as the default.

    remove_default(key: str) → None[source]¶

    Remove a default value on this site configuration.

    This will remove only defaults registered on this site configuration. This does not affect global defaults.

    Parameters:

    key (str) – The settings key to remove the default for.

    clear_defaults() → None[source]¶

    Clear all default values for this site configuration.

    This will clear only defaults registered on this site configuration. This does not affect global defaults.

    get_defaults() → Dict[str, Union[djblets.util.typing.JSONDict, djblets.util.typing.JSONDictImmutable, djblets.util.typing.JSONList, djblets.util.typing.JSONListImmutable, None, bool, float, int, str]][source]¶

    Return all defaults for this site configuration.

    This will return only defaults registered on this site configuration. The result does not include global defaults.

    Returns:

    A dictionary of all registered defaults for settings.

    Return type:

    dict

    is_expired() → bool[source]¶

    Return whether or not this SiteConfiguration is expired.

    If the configuration is expired, it will need to be reloaded before accessing any settings.

    Returns:

    Whether or not the current state is expired.

    Return type:

    bool

    save(*args, clear_caches: bool = True, **kwargs) → None[source]¶

    Save the site configuration to the database.

    By default, saving will clear the caches across all processes/servers using this site configuration, causing them to be re-fetched on the next request.

    Parameters:
    • clear_caches (bool, optional) – Whether to clear the caches. This is True by default.

    • **kwargs (dict) – Additional keyword arguments to pass to the parent method.

    __str__() → str[source]¶

    Return a string version of the site configuration.

    The returned string will list the associated site’s domain and the stored application version.

    Returns:

    The string representation of the site configuration.

    Return type:

    str

    __annotations__ = {}¶
    get_settings_json()¶
    id¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    set_settings_json(json)¶
    site_id¶

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • SiteConfigurationSettingsValue
    • SiteConfigurationSettings
    • SiteConfigSettingsWrapper
      • SiteConfigSettingsWrapper.__init__()
      • SiteConfigSettingsWrapper.siteconfig
      • SiteConfigSettingsWrapper.__getattr__()
      • SiteConfigSettingsWrapper.__annotations__
    • SiteConfiguration
      • SiteConfiguration.version
      • SiteConfiguration.settings
      • SiteConfiguration.add_global_defaults()
      • SiteConfiguration.add_global_default()
      • SiteConfiguration.remove_global_default()
      • SiteConfiguration.clear_global_defaults()
      • SiteConfiguration.get_global_defaults()
      • SiteConfiguration.__init__()
      • SiteConfiguration.site
      • SiteConfiguration.get()
      • SiteConfiguration.set()
      • SiteConfiguration.add_defaults()
      • SiteConfiguration.add_default()
      • SiteConfiguration.remove_default()
      • SiteConfiguration.clear_defaults()
      • SiteConfiguration.get_defaults()
      • SiteConfiguration.is_expired()
      • SiteConfiguration.save()
      • SiteConfiguration.__str__()
      • SiteConfiguration.__annotations__
      • SiteConfiguration.get_settings_json()
      • SiteConfiguration.id
      • SiteConfiguration.set_settings_json()
      • SiteConfiguration.site_id