简体   繁体   中英

Django url pathing, home url always overwriting path('', views.home, name='home')

from django.urls import path 
from . import views

urlpatterns = [
    path('signup/', views.signup, name='signup'),  
    path('', views.home, name='home'),

]

this is my code for the URLs under my something I call timetable

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('signup/' , include('timetable.urls')),
    path('', include('timetable.urls')),
]

this is the code for the main urls.py

so I know that the call to the other url.py works as if I take the '' (home) URL out it redirects to the right URL (the view that I have in place) but if I have the home URL in it just always goes straight to that URL, is there any way like in react where I can do Exact or do you guys know of any solution for this that is simple

The way it's configured, 127.0.0.1:8000/ and 127.0.0.1:8000/signup/ will go to views.home and 127.0.0.1:8000/signup/signup/ will go to views.signup . Remove the 'signup/' path from your main urls.py file and it should work as expected.

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('timetable.urls')),
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM