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<format>[a-z0-9]+)/?\.(?P<format>[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...
This commit is contained in:
zhaojiedi1992 2018-12-01 14:03:27 +08:00 committed by GitHub
parent 5a54f897ec
commit b715996037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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