我正在升级到 Django 1.5,它已经弃用了通用视图。我正在使用使用通用视图的 django-voting。我不确定如何将其转换为基于类的视图:
from django.conf.urls.defaults import *
from django.views.generic.list_detail import object_list
from django.core.context_processors import request
from django.shortcuts import get_object_or_404, render_to_response
from blog.models import Blog
from voting.views import vote_on_object
from voting.models import Vote
import operator
urlpatterns = patterns('',
url(r'^links/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/?$',
vote_on_object,
dict(
model=Blog,
template_object_name='link',
template_name='blog/link_confirm_vote.html',
allow_xmlhttprequest=True,
),
name="link_vote",)
)