我最近从 django 1.4 迁移到 django 1.5,我收到了这个错误
ViewDoesNotExist: Could not import django.views.generic.date_based.archive_index. Parent module django.views.generic.date_based does not exist.
谷歌搜索给了我基于功能的视图已被贬低。我正在尝试迁移到基于类的视图,但发现它很困难。这是我的意见.py
from app.models import Season
from django.conf.urls import *
from cms.models import News, File
def get_extra_context():
past_seasons = Season.objects.filter(in_progress = False)
try:
current_season = Season.objects.get(in_progress = True)
except Season.DoesNotExist:
current_season = None
files = File.objects.all().order_by('-id')[:5]
output = {
'current_season': current_season,
'past_seasons': past_seasons,
'files': files,
}
return output
dictionary = {
'queryset': News.objects.all(),
'date_field': 'date',
'extra_context': get_extra_context(),
}
urlpatterns= patterns(
'django.views.generic.date_based',
url(
r'(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
'object_detail',
dict(dictionary, slug_field = 'slug', template_name = 'cms/news/object.html'),
name='object'
),
url(
r'^$',
'archive_index',
dict(dictionary, template_name = 'cms/news/list.html'),
name='list'
)
)
我无法将其转换为基于类的视图。任何身体都可以提供帮助。字典是我想放入上下文的对象。
提前致谢。
//鼠