这是一个django1.4的显示信息列表的函数。怎么改成django1.5的 DetaiView 的可用函数啊?
这是一个django1.4的显示信息列表的函数。怎么改成django1.5的 DetaiView 的可用函数啊?
def user_msg_list_page(request, username):
user = get_object_or_404(User, username=username)
return list_detail.object_list(
request,
queryset=user.msg_set.order_by('-id'),
paginate_by=ITEMS_PER_PAGE,
template_name = 'message/user_msg_list_page.html',
template_object_name='msg',
extra_context = {'username':username}
)
这是一个django1.4的显示信息列表的函数。怎么改成django1.5的 DetaiView 的可用函数啊?
我是这样写的:
views.py :
class msg_detail_page(DetailView):
model = Msg
queryset = Msg.objects.all()
def m_d_p(request, message_id):
object_id = message_id
msg.clickcount +=1
msg.save()
url(r'^detail/(\d+)/$', msg_detail_page.as_view(
context_object_name='msg_list',
template_name='message/msg_detail_page.html'
)),
Exception Type: AttributeError at /detail/6/
Exception Value: Generic detail view msg_detail_page must be called with either an object pk or a slug.
url(r’^(?P<pk>\d+)/$’,
DetailView.as_view(
model=Poll,
template_name=’polls/detail.html’)),