from django.shortcuts import render, HttpResponse
# Create your views here.
def index(request):
return render(request, 'platoweb/index.html')
def about(request):
return render(request, 'platoweb/about.html')
这是views.py文件。django将不同链接重定向到同一页
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index.html'),
url(r'^$', views.about, name='about.html'),
]
这是应用urls.py
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
admin.autodiscover()
urlpatterns = [
url(r'^platoweb/index.html', include('platoweb.urls')),
url(r'^platoweb/about.html', include('platoweb.urls')),
url(r'^admin/', admin.site.urls),
# . url(r'^posts/', include("posts.urls", namespace='posts')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
这是全球urls.py
本质上讲,我试图打两个不同的网址,index.html,然后约。 HTML(以及更多)。但是,当我运行它时,index.html和about.html都会重定向到index.html。
我测试了这两个html文件,他们工作得很好。任何想法或想法?
你的url模式是相同的索引和约你的views.py –
通过网址模式你的意思是在我的返回语句中的网址对吗?一个指向索引,另一个指向大约 –