fairdm.conf.setup#

FairDM configuration setup entry point.

This module provides setup(), the single call a portal’s settings module makes to obtain a complete Django configuration.

Resolved environment. Taken literally from the DJANGO_ENV environment variable, defaulting to production when unset. Not validated against an allowlist: any name is valid, including one nothing ships an override for.

Environment files, read in this order, later files not overriding a variable already set in the process environment except where noted:

  1. stack.env, beside the portal’s base_dir, if present.

  2. stack.<environment>.env, beside base_dir, if present.

  3. The explicit env_file= argument, if given — this one does overwrite variables already set, including by the two files above.

Layers, applied in this order, each later layer overriding the same setting in an earlier one:

  1. The production baseline — every module under fairdm/conf/settings/.

  2. FairDM’s own override module for the resolved environment, if it ships one. Only development.py today.

  3. Settings contributed by addons named in the addons= argument.

  4. The portal’s own override module for the resolved environment, resolved beside its settings module regardless of directory name.

  5. Assignments the portal’s settings module makes after setup() returns — the only supported way to override a FairDM-owned setting.

Layers 2 and 4 are both selected by existence, not from a fixed list of permitted names: if no module named after the resolved environment exists, that layer is skipped without error.

Module Contents#

Functions#

setup

Initialize FairDM configuration with environment-specific settings.

Data#

API#

logger#

‘getLogger(…)’

setup(apps: list[str] | None = None, addons: list[str] | None = None, base_dir: pathlib.Path | None = None, env_file: str | None = None) → None[source]#

Initialize FairDM configuration with environment-specific settings.

The main entry point for portal configuration. See the module docstring for the resolved environment, the environment files and the five layers this composes into the caller’s global namespace.

Args: apps: List of portal-specific Django apps to include in INSTALLED_APPS. addons: List of FairDM addon packages to enable. base_dir: Project base directory (auto-detected if not provided). env_file: Optional path to .env file to load.

Raises: ImproperlyConfigured: An addon’s setup module fails while applying in production.

Example: >>> import fairdm >>> fairdm.setup( … apps=[“my_portal_app”], … addons=[“fairdm_discussions”], … )