aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide
diff options
context:
space:
mode:
authorTom Christie2013-12-23 14:38:51 +0000
committerTom Christie2013-12-23 14:38:51 +0000
commit75e872473197f9b810c9daf348cb452faadac476 (patch)
treef6fb48e0aea492834e7b4e3875cca27067bdac4c /docs/api-guide
parentd24ea39a4e4131486d45492339dcbbfefb6a933b (diff)
downloaddjango-rest-framework-75e872473197f9b810c9daf348cb452faadac476.tar.bz2
Fuller notes on the 'base_name' argument. Closes #1160.
Diffstat (limited to 'docs/api-guide')
-rw-r--r--docs/api-guide/routers.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index 895589db..7efc140a 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -37,6 +37,18 @@ The example above would generate the following URL patterns:
* URL pattern: `^accounts/$` Name: `'account-list'`
* URL pattern: `^accounts/{pk}/$` Name: `'account-detail'`
+---
+
+**Note**: The `base_name` argument is used to specify the initial part of the view name pattern. In the example above, that's the `user` or `account` part.
+
+Typically you won't *need* to specify the `base-name` argument, but if you have a viewset where you've defined a custom `get_queryset` method, then the viewset may not have any `.model` or `.queryset` attribute set. If you try to register that viewset you'll see an error like this:
+
+ 'base_name' argument not specified, and could not automatically determine the name from the viewset, as it does not have a '.model' or '.queryset' attribute.
+
+This means you'll need to explicitly set the `base_name` argument when registering the viewset, as it could not be automatically determined from the model name.
+
+---
+
### Extra link and actions
Any methods on the viewset decorated with `@link` or `@action` will also be routed.