# -*- coding: utf-8 -*-
from django.conf.urls import patterns,
include, url
from django.contrib import
admin
admin.autodiscover()
urlpatterns =
patterns(‘‘,
url(r‘^admin/‘,
include(admin.site.urls)),
url(r‘^blog/‘,
include(‘blog.urls‘)), # 包含blog的URL
)
3. 创建视图list
修改文件"blog\views.py":
# -*- coding: utf-8 -*-
from django.shortcuts import
render_to_response
from django.template import
RequestContext
from blog.models import Group,
Article
def show_blogs(request):
"""显示所有日志"""
group_list =
Group.objects.all()
article_list =
Article.objects.all()
return
render_to_response(‘list.html‘, {
‘group_list‘: group_list,
‘article_list‘: article_list,
},
context_instance=RequestContext(request))