Configurations¶
drf-corekit is configured through the Django settings module.
Logging¶
TRANSACTION_ID_HEADER¶
Name of the HTTP header used to store and propagate the transaction identifier.
An incoming value is used only if it is 1 to 64 characters of letters, digits, _, . or -. Anything else is replaced by a generated tx-<uuid>.
| Property | Value |
|---|---|
| Key | LOGGING.TRANSACTION_ID_HEADER |
| Type | str |
| Required | No |
| Default | "X-Transaction-ID" |
Example¶
LOG_DIR_PATH¶
Base directory used by components that write log files, such as ScriptCommand.
Generated command logs are stored under:
| Property | Value |
|---|---|
| Key | LOGGING.LOG_DIR_PATH |
| Type | str |
| Required | No |
| Default | "logs" |
Example¶
Example Output¶
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.
HTTP¶
CLIENT_IP_HEADER¶
Name of the header your own proxy sets to the real client IP, used by
get_client_ip, rate throttles and request logs.
| Property | Value |
|---|---|
| Key | HTTP.CLIENT_IP_HEADER |
| Type | str \| None |
| Default | None (use REMOTE_ADDR) |
Warning
Set this only if the proxy always overwrites the header. Client sent headers are otherwise ignored, so they cannot be used to dodge throttles.
User¶
USERNAME_VALIDATORS¶
Validators applied to the username field on AbstractUser.
Supports three states:
- Key absent —
UnicodeUsernameValidatoris 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¶
USERNAME_MAX_LENGTH¶
Maximum character length enforced on the username field.
| Property | Value |
|---|---|
| Key | USER.USERNAME_MAX_LENGTH |
| Type | int |
| Required | No |
| Default | 150 |