API¶
Organize Django settings into multiple files and directories.
Easily override and modify settings. Use wildcards and optional settings files.
- class _Optional[source]¶
Bases:
strWrap a file path with this class to mark it as optional.
Optional paths don’t raise an
OSErrorif file is not found.
- optional(filename)[source]¶
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)[source]¶
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()orNone).
- 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 )