【发布时间】:2019-01-12 04:40:57
【问题描述】:
我正在尝试使用 django 创建一个小型 Web 应用程序,我是这方面的新手,我正在尝试在主页上创建一个主页和一个关于将页面重新加载到关于页面的按钮
这是我的 index.html
<!DOCTYPE html>
<html>
<head>
<title>Simple App</title>
<h1> Testing the simple app</h1>
</head>
<body>
<a href="/about/">About </a>
</body>
</html>
这是我的 about.html
<!DOCTYPE html>
<html>
<head>
<title>Simple App</title>
<h1> Testing the simple app</h1>
</head>
<body>
This is the about page
</body>
</html>
这是我的观点.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
class HomePageView(TemplateView):
def get(self, request, **kwargs):
return render(request, 'index.html', context=None)
# Add this view
class AboutPageView(TemplateView):
template_name = "about.html"
和 urls.py
from django.conf.urls import url
from django.contrib import admin
from homepage import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', views.HomePageView.as_view()),
url(r'^about/$',views.AboutPageView.as_view()),
]
但是当我点击关于按钮时什么都没有发生
【问题讨论】:
标签: python django django-templates django-generic-views