diff options
| author | Tom Christie | 2014-01-13 07:34:58 -0800 |
|---|---|---|
| committer | Tom Christie | 2014-01-13 07:34:58 -0800 |
| commit | 4ab97843e8ebdb037110e09d9e2a7cd45e61a406 (patch) | |
| tree | 937cf83b484a45794b7f942fb6a1c9a78f46f669 /docs | |
| parent | a90796c0f0d9db1a7d9bfaca8fbdfed22435c628 (diff) | |
| parent | 899381575a6038f550a064261ed5c6ba0655211b (diff) | |
| download | django-rest-framework-4ab97843e8ebdb037110e09d9e2a7cd45e61a406.tar.bz2 | |
Merge pull request #1333 from bodylabs/2.4.0+lookup_regex
Let viewsets specify their regex
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/api-guide/routers.md | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md index 846ac9f9..249e99a4 100644 --- a/docs/api-guide/routers.md +++ b/docs/api-guide/routers.md @@ -83,6 +83,12 @@ This behavior can be modified by setting the `trailing_slash` argument to `False Trailing slashes are conventional in Django, but are not used by default in some other frameworks such as Rails. Which style you choose to use is largely a matter of preference, although some javascript frameworks may expect a particular routing style. +The router will match lookup values containing any characters except slashes and period characters. For a more restrictive (or lenient) lookup pattern, set the `lookup_value_regex` attribute on the viewset. For example, you can limit the lookup to valid UUIDs: + + class MyModelViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet): + lookup_field = 'my_model_id' + lookup_value_regex = '[0-9a-f]{32}' + ## DefaultRouter This router is similar to `SimpleRouter` as above, but additionally includes a default API root view, that returns a response containing hyperlinks to all the list views. It also generates routes for optional `.json` style format suffixes. |
