我是 Django 新手,非常感谢您的帮助。
我从一本关于 Django 的旧书中提到了下面提到的一段代码。但是,django.views.generic.list_detail
已被弃用。有人能告诉我如何用 重写这段代码django.views.generic.list.ListView
吗?
from django.conf.urls import patterns, include, url
from cmsproject.cms.models import Story
info_dict = {'queryset': Story.objects.all(), 'template_object_name': 'story'}
urlpatterns = patterns('django.views.generic.list_detail',
url(r'^(?P<slug>[-\w]+)/$', 'object_detail', info_dict, name="cms-story"),
url(r'^$', 'object_list', info_dict, name="cms-home"),
)