Python實作子頁面的解決方案
我想從另一個html文件(Magamrol.html)中調用另一個html文件,但是當我嘗試打開時出現了以下情況:
使用在mysite.urls中定義的URLconf,Django按照以下順序嘗試這些URL模式:
1 2 3 | [name= 'index' ]
admin/
polls/
|
目前路徑Magamrol.html與上述任何模式都不符。
我的應用程式是polls,專案名稱是mysite。
mysite\polls\urls.py:
1 2 3 4 5 6 7 8 9 | 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:
1 2 3 4 5 6 7 8 9 10 11 12 | 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:
1 2 3 4 5 6 7 8 9 10 | 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' ))
]
|
有人知道如何解決這個問題嗎?
謝謝