2014-07-10 132 views
0

我試圖將我的視圖遷移到django 1.5。我跟着互聯網上發現了一個例子,但現在我有一些問題,我不能由我自己解決......Django 1.5遷移問題

這種觀點給我一個錯誤:SubListView() received an invalid keyword 'template_object_name'. as_view only accepts arguments that are already attributes of the class

這是視圖:

def forum(request, slug): 
    try: 
     f = Forum.objects.for_groups(request.user.groups.all()).select_related().get(slug=slug) 
    except Forum.DoesNotExist: 
     raise Http404 

    form = CreateThreadForm() 
    child_forums = f.child.for_groups(request.user.groups.all()) 
    callable = SubListView.as_view(
         queryset=f.thread_set.select_related().all(), 
         paginate_by=FORUM_PAGINATION, 
         template_object_name="thread", 
         template_name='forum/thread_list.html', 
         extra_context = { 
          'forum': f, 
          'child_forums': child_forums, 
          'form': form, 
         }) 
    return callable(request) 

,這是相關SubListView

class SubListView(ListView): 
    extra_context = {} 
    def get_context_data(self, **kwargs): 
     context = super(SubListView, self).get_context_data(**kwargs) 
     context.update(self.extra_context) 
     return context 

任何想法?

回答