Currently learning about Auth0 and django.
https://github.com/auth0-blog/django-feed-auth0/blob/main/feed/feed/urls.py
I saw the URL pattern is like this
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('feedapp.urls')),
path('', include('social_django.urls')),
]
From what i learned previously we should have 1 path('', views.xyz) as it will be redundant to have same url pointing to the different views unless we have put other input like int or str. But auth0 have same path with other views.
Not really understand why is it okay for it to be like this? Hope you guys can explain to me.
Thanks
CodePudding user response:
As explained in Django documentation, Django will parse through each URL pattern, in order, and stops at the first one that matches the requested URL.
As long as the path in "feedapp.urls" and "social_django.urls" are unique, everything will be fine. If some path are not unique, the first one found will be used. In your case, those in "feedapp.urls".
To ensure uniqueness, we can use named path to remove ambiguity Including other URLconfs.
Hope the explanation will help you