Performance: URL parameters with angle brackets
This affects the routing and URL resolution speed during page load and navigation.
re_path(r'^article/(?P<title>[-\w]+)/(?P<id>\d+)/$', views.article_detail)path('article/<str:title>/<int:id>/', views.article_detail)| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple complex angle bracket parameters | 0 (server-side) | 0 | 0 | [!] OK |
| Simplified regex named groups for parameters | 0 (server-side) | 0 | 0 | [OK] Good |
<int:id> in a Django URL pattern do?<int:id> captures an integer named 'id'.path('post/<slug:post_slug>/', views.post_detail) uses path('post/<slug:post_slug>/', views.post_detail), which is valid Django syntax.path('post/<slug:post_slug>/', views.post_detail) [OK]path('user/<int:user_id>/', views.profile), what will user_id be if the URL is /user/42/?path('article/<int:id>', views.detail)path('profile/<slug:username>/post/<int:post_id>/', views.post_view) uses <slug:username> and <int:post_id>, matching requirements perfectly.path('profile/<slug:username>/post/<int:post_id>/', views.post_view) [OK]Pass the test and this pattern moves unknown