Settings
All configuration lives in a single RN_FORGE_DJANGO dict in your Django
settings module:
RN_FORGE_DJANGO = {
"AUTH": {
"PROBLEM_TYPE_BASE": "https://errors.example.com/", # required to mount the /auth routes
},
"DRF": {
"TRANSFER": {
"MAX_ROWS": 10_000, # rows per export, import or batch request; None = no cap
},
"PAGINATION": {
"PAGE_SIZE": 50, # default page size
"PAGE_SIZE_QUERY_PARAM": "pageSize",
"MAX_PAGE_SIZE": 200, # larger requests are clamped, never rejected
},
"CASING": {
"ENABLED": True, # camelCase renderer/parser; False = plain JSON
},
},
}
DRF.PAGINATION is read at request time by CursorPagination and
LegacyPageNumberPagination; a page_size or max_page_size set on a
pagination subclass wins over it. DRF.CASING switches CamelCaseJSONRenderer
and CamelCaseJSONParser — see OpenAPI and camelCase.
Read the resolved, typed settings at runtime via the module-level facade:
from rn_forge.django.settings import rn_forge_django_settings
max_rows = rn_forge_django_settings.drf.transfer.max_rows
problem_type_base = rn_forge_django_settings.auth.problem_type_base
rn_forge_django_settings is a frozen dataclass tree rebuilt automatically
whenever Django's setting_changed signal fires for RN_FORGE_DJANGO — this is
what makes override_settings(RN_FORGE_DJANGO=...) work transparently in tests.
Every field has a default, so an empty or missing RN_FORGE_DJANGO dict is
valid.
Adding a configurable option
The facade is a frozen dataclass tree — RnforgeDjangoSettings →
AuthSettings/DRFSettings → nested settings — built once by
_build_settings() in
settings.py
and rebuilt by the setting_changed handler. A new option needs three edits, in
this order:
- A field on the relevant
*SettingsDictTypedDict, naming theRN_FORGE_DJANGOkey (uppercase, as the dict is written). - A field on the matching frozen dataclass, snake_cased, with a default — every
field has one, so an absent
RN_FORGE_DJANGOstays valid. - Extraction in
_build_settings(), usingDictUtils.get/_get_mappingfor the nested path ("DRF.VIEWS", say).
Skipping step 3 leaves the field permanently at its default, which no test catches unless it asserts the non-default value.