Skip to content

Configurations

drf-corekit is configured through the Django settings module.

DRF_COREKIT = {}

Logging

TRANSACTION_ID_HEADER

Name of the HTTP header used to store and propagate the transaction identifier.

Property Value
Key LOGGING.TRANSACTION_ID_HEADER
Type str
Required No
Default "X-Transaction-ID"

Example

DRF_COREKIT = {
    "LOGGING": {
        "TRANSACTION_ID_HEADER": "X-Correlation-ID",
    }
}

LOG_DIR_PATH

Base directory used by components that write log files, such as ScriptCommand.

Generated command logs are stored under:

<LOG_DIR_PATH>/scripts/<command_name>/
Property Value
Key LOGGING.LOG_DIR_PATH
Type str
Required No
Default "logs"

Example

DRF_COREKIT = {
    "LOGGING": {
        "LOG_DIR_PATH": BASE_DIR / "logs",
    }
}

Example Output

logs/
└── scripts/
    └── sync_users/
        └── 20260606_090000_a1b2c3d4.log

Warning

LOG_DIR_PATH must not be None when using ScriptCommand.

An ImproperlyConfigured exception will be raised if a command attempts to create execution logs without a configured log directory.

User

USERNAME_VALIDATORS

Validators applied to the username field on AbstractUser.

Supports three states:

  • Key absentUnicodeUsernameValidator is used (default).
  • None — no validators are applied.
  • List of dotted import paths — the listed validators are instantiated and used instead.
Property Value
Key USER.USERNAME_VALIDATORS
Type list[str] | None
Required No
Default UnicodeUsernameValidator()

Example — custom validator

DRF_COREKIT = {
    "USER": {
        "USERNAME_VALIDATORS": [
            "myapp.validators.MyCustomUsernameValidator",
        ]
    }
}

Example — no validators

DRF_COREKIT = {
    "USER": {
        "USERNAME_VALIDATORS": None,
    }
}

USERNAME_MAX_LENGTH

Maximum character length enforced on the username field.

Property Value
Key USER.USERNAME_MAX_LENGTH
Type int
Required No
Default 150

Example

DRF_COREKIT = {
    "USER": {
        "USERNAME_MAX_LENGTH": 80,
    }
}