From b7159960378f4575fb6e9bdcface1c3070c90a5e Mon Sep 17 00:00:00 2001 From: zhaojiedi1992 Date: Sat, 1 Dec 2018 14:03:27 +0800 Subject: [PATCH] remove urlpatterns = format_suffix_patterns(urlpatterns) if i use If I use DefaultRouter, the original urlpatterns = format_suffix_patterns(urlpatterns) need to be removed, otherwise the error message will be as follows: django.core.exceptions.ImproperlyConfigured: "^snippets\.(?P[a-z0-9]+)/?\.(?P[a-z0-9]+)/?$ " is not a valid regular expression: redefinition of group name 'format' as group 2; was group 1 at position 40 Performing system checks... --- docs/tutorial/6-viewsets-and-routers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/6-viewsets-and-routers.md b/docs/tutorial/6-viewsets-and-routers.md index 1d4058813..092f0666f 100644 --- a/docs/tutorial/6-viewsets-and-routers.md +++ b/docs/tutorial/6-viewsets-and-routers.md @@ -121,7 +121,7 @@ Here's our re-wired `snippets/urls.py` file. Registering the viewsets with the router is similar to providing a urlpattern. We include two arguments - the URL prefix for the views, and the viewset itself. -The `DefaultRouter` class we're using also automatically creates the API root view for us, so we can now delete the `api_root` method from our `views` module. +The `DefaultRouter` class we're using also automatically creates the API root view for us, so we can now delete the `api_root` method and `format_suffix_patterns` from our `views` module. ## Trade-offs between views vs viewsets