0

I just imported generic views successfully and here comes the problem when I want to use them in views the server just gives an error directed to "." (period) in generic.ListView...

Here is the code I am currently working on.

def IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'question_list'
    def get_queryset(self):
        return Question.objects.order_by('-published_date')[:5]
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

It was very idiotic error. I just was defining traditional views with "def" i.e functions while generic views takes a view (__.as_view()) if that is a class. So by just replacing the def with class I successfully evaded the Error

0

You have defined your view with def, change it to class,

class IndexView(generic.ListView):

Generic views are classes, which needs to be inherited.

zaidfazil
  • 9,017
  • 2
  • 24
  • 47