Skip to content

Commit ab5e821

Browse files
Document new router settings
1 parent f33aa98 commit ab5e821

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

docs/settings.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ source_filename: settings
66
To set DRF docs' settings just include the dictionary below in Django's `settings.py` file.
77

88
REST_FRAMEWORK_DOCS = {
9-
'HIDE_DOCS': True
9+
'HIDE_DOCS': True,
10+
'MODULE_ROUTERS': {
11+
'project.accounts.urls': 'accounts_router',
12+
},
13+
'DEFAULT_MODULE_ROUTER': 'router',
14+
'DEFAULT_ROUTER': 'project.urls.default_router',
1015
}
1116

1217

@@ -21,9 +26,29 @@ You can use hidden to prevent your docs from showing up in different environment
2126

2227
Then set the value of the environment variable `HIDE_DRFDOCS` for each environment (ie. Use `.env` files)
2328

29+
##### MODULE_ROUTERS
30+
Use this setting to manually bind url modules to a router instance. The router must be defined in the module, or imported in the module.
31+
For instance, if the router of an app called 'gifts' is 'gifts_router', and the router of another app called 'scuba_diving' is 'scuba_diving_router', the MODULE_ROUTERS setting should look like:
32+
33+
'MODULE_ROUTERS': {
34+
'gifts.urls': 'gift_router',
35+
'scuba_diving.urls': 'scuba_diving_router'
36+
}
37+
38+
If there is no entry for a given module, if this setting is not set, or if it is set to None, the value of the DEFAULT_MODULE_ROUTER setting is used.
39+
40+
##### DEFAULT_MODULE_ROUTER
41+
When set, the value of this setting will be used to find a router for a urls module. If there is no router having the DEFAULT_MODULE_ROUTER name, the setting is ignored and the value of DEFAULT_ROUTER is used.
42+
43+
##### DEFAULT_ROUTER
44+
When defined, this setting must describe a python dotted path leading to the router that should be used when MODULE_ROUTERS and DEFAULT_MODULE_ROUTER are not set.
45+
This parameter is useful when there is only one router for your whole API.
46+
2447
### List of Settings
2548

26-
| Setting | Type | Options | Default |
27-
|---------|---------|-----------------|---------|
28-
|HIDE_DOCS| Boolean | `True`, `False` | `False` |
29-
| | | | |
49+
| Setting | Type | Options | Default |
50+
|---------------------|-----------------------------------------------------------|-----------------|---------|
51+
|HIDE_DOCS | Boolean | `True`, `False` | `False` |
52+
|MODULE_ROUTERS | dict of python dotted paths -> router instance name | | `None` |
53+
|DEFAULT_MODULE_ROUTER| str representing a default router instance name | | `None` |
54+
|DEFAULT_ROUTER | str representing a python dotted path to a router instance| | `None` |

0 commit comments

Comments
 (0)