Home > OS >  How to Include multiple urls to one django app
How to Include multiple urls to one django app

Time:09-08

In django I've an application 'users' which has a custom user model, a custom registration and profile views, How can I include the app's urls and django's default login and logout urls to the same 'users' app at the same time as below:

from django.urls import path, include

urlpatterns = [
    path('users/', include("django.contrib.auth.urls")), # Django's default authentication urls for login and logout views
    path('users/', include('users.urls')), # 'users' app custom urls for the registration and profile views
]

CodePudding user response:

directly it is not possible. In your case:

# users.urls.py

from django.contrib.auth.urls import urlpatterns

urlpatterns  = [
    path(users view1),
    path(users view2),
    ...
    ]

in main urls.py

urlpatterns = [
    path('users/', include('users.urls')), # 'users' app custom urls for the registration and profile views
    ...
]
  • Related