API

setman

get_version

setman.get_version(version=None)[source]

Return setman version number in human readable form.

You could call this function without args and in this case value from setman.VERSION would be used.

settings

setman.settings is global instance of LazySettings class.

class setman.lazy.LazySettings(settings=None, prefix=None, parent=None)[source]

Simple proxy object that accessed database only when user needs to read some setting.

revert()

Revert settings to default values.

save()[source]

Save customized settings to the database.

setman.helpers

setman.helpers.get_config(name, default=None)[source]

Helper function to easy fetch name from database or django settings and return default value if setting key isn’t found.

But if not default value is provided (None) the AttributeError exception can raised if setting key isn’t found.

If name is one of available app_name function raises ValueError cause cannot to returns config value.

For fetching app setting use next definition: <app_name>.<setting_name>.

setman.models

Settings

class setman.models.Settings(*args, **kwargs)[source]

Store all custom project settings in data field as json dump.

Model also have two more fields:

  • create_date - Time when model instance has been created.
  • update_date - Time when model instance has been changed last time.
is_setting_name(name)

Is name a valid setting name or not?

revert(app_name=None)

Revert all stored settings to default values.

validate_unique(exclude=None)[source]

Check that no else Settings insances has been created.

setman.utils

Setting

class setman.utils.Setting(**kwargs)[source]

Base class for setting values that can provided in configuration definition file.

The class has next attributes:

  • name
  • type
  • default
  • required
  • label
  • help_text
  • validators
  • field
  • field_args
  • field_kwargs

The last three attributes can be provided only in Python module, when all other attrs can read from configuration definition file.

initial[source]

Read real setting value from database or if impossible - just send default setting value.

to_field(**kwargs)[source]

Convert current setting instance to form field.

You should provide kwargs and all values from here would be used when initing field instance instead of Setting attributes.

to_python(value)[source]

Convert setting value to necessary Python type. By default, returns same value without any conversion.

update(**kwargs)

Update attributes for current setting instance.

validators

Lazy loaded validators.

Table Of Contents

Previous topic

Django admin support

This Page