[Django]-Django wrong url?

2πŸ‘

βœ…

The detail path will capture the URLs that are supposed to fire the blog_id path. Indeed, in the games.urls we see:

path('<slug:platform>/<slug:slug>',views.oyun,name='detail'),

whereas for the blog_id, the complete URL path is:

     'blog/<slug:slug>'

This thus means that if you visit blog/foo, it will fire the oyun view with 'blog' as value for the platform variable, and 'foo' as value for the slug variable.

You can swap the paths, such that it will first inspect the items with a blog/ prefix, and only will fire the oyun view, if that is not the case:

urlpatterns = [
    path('blog',include('blogs.urls')),  # ← first the blog/ paths.
    path('',include('games.urls')),
]

Leave a comment