Jump to >

djblets.siteconfig.forms

A base form for working with settings stored on SiteConfigurations.

class SiteSettingsForm(siteconfig: djblets.siteconfig.models.SiteConfiguration, *args, **kwargs)[source]

Bases: djblets.forms.forms.key_value_form.KeyValueForm

A base form for loading/saving settings for a SiteConfiguration.

This is meant to be subclassed for different settings pages. Any fields defined by the form will be loaded/saved automatically.

__init__(siteconfig: djblets.siteconfig.models.SiteConfiguration, *args, **kwargs) None[source]

Initialize the form.

Parameters
request: django.http.request.HttpRequest

The HTTP request used for this form.

Type

django.http.HttpRequest

siteconfig: djblets.siteconfig.models.SiteConfiguration

The site configuration settings that are loaded from and saved to.

Type

djblets.siteconfig.models.SiteConfiguration

get_key_value(key: str, default: Optional[object] = None) Optional[object][source]

Return the value for a SiteConfiguration settings key.

Parameters
  • key (str) – The settings key.

  • default (object, unused) – The default value from the form, which will be ignored, so that the registered siteconfig defaults will be used.

Returns

The resulting value from the settings.

Return type

object

__annotations__ = {'request': 'HttpRequest', 'siteconfig': 'SiteConfiguration'}
declared_fields = {}
set_key_value(key: str, value: object) None[source]

Set the value for a SiteConfiguration settings key.

Parameters
  • key (str) – The settings key.

  • value (object) – The settings value.

save_instance() None[source]

Save the SiteConfiguration instance.