# API

Organize Django settings into multiple files and directories.

Easily override and modify settings. Use wildcards and optional settings files.

class _Optional

  Bases: `str`

  Wrap a file path with this class to mark it as optional.

  Optional paths don’t raise an `OSError` if file is not found.

optional(filename)

  This function is used for compatibility reasons.

  It masks the old optional class with the name error. Now invalid-name is removed from pylint.

  Parameters:

    filename (`Optional`[`str`]) – the filename to be optional.

  Return type:

    `str`

  Returns:

    New instance of `_Optional`.

include(*args, scope=None)

  Used for including Django project settings from multiple files.

  Parameters:

    - *args (`str`) – File paths (`glob` - compatible wildcards can be used).

    - scope (`dict`[`str`, `Any`] | `None`) – Settings context (`globals()` or `None`).

  Raises:

    OSError – if a required settings file is not found.

  Return type:

    `None`

  Usage example:

      from split_settings.tools import optional, include

      include(
          'components/base.py',
          'components/database.py',
          optional('local_settings.py'),

          scope=globals(),  # optional scope
      )