Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to redirect urls?

this is my main urls.py

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

i want that any url enter by user it will redirect to shop.urls and find here.
like if user enter /index it will search index in shop.urls not in main urls

my shop.urls

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index),
    path('index', views.index),
]

enter image description here

>Solution :

You need to add / at the end of route so:

urlpatterns = [
    path('', views.index),
    path('index/', views.index),
]

Then enter the requested url as http://127.0.0.1:8000/index/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading