不必为每个页面创建html模板。
你必须在
urls.py
:
url(r'^(P<list_name>\w+)/$', views.your_view)
因此,与其有许多具有相同结构的模板,不如只呈现一个具有所需信息的模板。
所以你的观点应该是这样的:
def your_view(request, list_name):
list = get_object_or_404(List, pk=list_name)
context = {
'list_info':list.info
}
return render(request, 'your_app/template.html', context)
当然,在这个例子中,需要有一个名为
List
在数据库中使用主键
list_name