I tested 1st Django web app project.
That app project redirects to http://127.0.0.1:8000/api/
when the URL of http://127.0.0.1:8000
is visited. The test was successful.
And then, I tested 2nd Django web app project.
That Django app should have redirected to http://127.0.0.1:8000/blog/
when the URL of http://127.0.0.1:8000
is visited but Django strangely redirects to http://127.0.0.1:8000/api/
which was target URL of 1st Django web app.
There is no /api/
URL configuration in 2nd project
Following code snippets are URL configuration of 2nd Django web app
# AskDjango_webfrontend_begin/askdjango/urls.py
urlpatterns = [
path('admin/', admin.site.urls),
# If the client enters in "localholst:8000", the page is redirected to localholst:8000/blog/
path("", RedirectView.as_view(url="/blog/", permanent=True)),
# If the client enters in "localholst:8000/blog/", connect to blog.urls.py
path("blog/", include("blog.urls")),
]
# AskDjango_webfrontend_begin/blog/urls.py
urlpatterns = [
path("",views.index,name="index"),
path('<int:pk>', views.post_detail, name="post_detail")
]
Your browser has cached the 302 Redirect
HTTP response from the first URL. Clear your cache and try again.
I recommend you to use different hostnames (such as 127.0.0.1
and 127.0.0.2
) while testing multiple web applications running on the same development PC.
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.