1

when I change the URL link path("admin/", admin.site.urls), to path("", admin.site.urls), it works fine

but raises API Not Found Error when I have the following urlpatterns.

I need path("api/", include("config.api_router")),

Note: when I use path("admin/", admin.site.urls), API works

lord stock
  • 1,191
  • 5
  • 32
DevXhub
  • 21
  • 3
  • can you post `config.api_router` urlpatterns' i guess you might need `path("api/", include("config.api_router.urls"))` – lord stock Dec 20 '22 at 11:08

1 Answers1

1

Django URL dispatcher runs through each URL pattern, in order, and stops at the first one that matches the requested URL. Try switching the order:

urlpatterns = [
    path("api/", include("config.api_router")),
    # other urls
    path("", admin.site.urls)
]
Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48