API¶
Organize Django settings into multiple files and directories.
Easily override and modify settings. Use wildcards and optional settings files.
- class _Optional[source]¶
Bases:
str
Wrap a file path with this class to mark it as optional.
Optional paths don’t raise an
IOError
if file is not found.
- optional(filename)[source]¶
This functions is used for compatibility reasons.
It masks the old optional class with the name error. Now invalid-name is removed from pylint.
- Parameters:
filename (
str
) – the filename to be optional.- Return type:
str
- Returns:
New instance of
_Optional
.
- include(*args, **kwargs)[source]¶
Used for including Django project settings from multiple files.
- Parameters:
*args (
str
) – File paths (glob
- compatible wildcards can be used).**kwargs – Settings context:
scope=globals()
orNone
.
- Raises:
IOError – 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 )