Nested urls.py challenge

I think if you read the docs for path() you would see very quickly why. But let’s look at two examples from your code:

    re_path(r'^recipes/?$', views.categories, name="categories"),
    re_path(r'^recipes/(?P<url_name>[\-_a-z0-9]+)/?$', views.category, name='category'),

which is shorter, easier to read and a lot easier to write as:

   path('recipes/', views.categories, name="categories"),
   path('recipes/<str:url_name>/', views.category, name='category'),

assuming you turn on the append slash feature of course, which I also highly recommend. The why in that case is that you want your urls to be predictable, and relative URLs to work as you’d expect. For example from /foo/bar/ the path .. would mean /foo/, but from /foo/bar it would mean /. This is super confusing, and a potential source of bugs.