Python solution to implement subpages
P粉267885948
P粉267885948 2023-09-17 22:34:31
0
1
635

I want to call another html file from another html file (Magamrol.html), but when I try to open it the following happens:

Using the URLconf defined in mysite.urls, Django tries these URL patterns in the following order:

[name='index'] admin/ polls/

The current path Magamrol.html does not match any of the above patterns.

My application is polls and the project name is mysite. mysite\polls\urls.py:

from django.urls import path from . import views from polls import views urlpatterns = [ path('', views.index, name="index"), path('', views.magamrol, name='Magamrol') ]

mysite\polls\views.py:

from django.http import HttpResponse from django.shortcuts import render def index(request): return HttpResponse("Üdvözöllek a honlapomon!") def index(request): return render(request, 'index.html') def magamrol(request): return render(request, 'Magamrol.html')

mysite\urls.py:

from django.contrib import admin from django.urls import include, path from polls import views urlpatterns = [ path('',views.index,name="index"), path('admin/', admin.site.urls), path('', include('polls.urls')) ]

Does anyone know how to solve this problem?

Thanks

P粉267885948
P粉267885948

reply all (1)
P粉776412597
urlpatterns = [ path('', views.index, name="index"), path('', views.magamrol, name='Magamrol') ]

You need to change the name of a URL path, for example:

path('magamrol/', views.magamrol, name='Magamrol')

When you use two identical endpoints, conflicts may occur.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!