# Not understanding with generic views

**URL:** <https://forum.djangoproject.com/t/not-understanding-with-generic-views/5297>\
**Category:** Forms & APIs\
**Created:** [November 20, 2020, 5:43am UTC](https://forum.djangoproject.com/t/not-understanding-with-generic-views/5297 "2020-11-20T05:43:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karki1234](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/karki1234/32/3308_2.png) [@Karki1234](https://forum.djangoproject.com/u/Karki1234)\
**Post date:** [November 20, 2020, 5:43am UTC](https://forum.djangoproject.com/t/not-understanding-with-generic-views/5297/1 "2020-11-20T05:43:17Z")

</div>

from django.http import HttpResponseRedirect  
from django.shortcuts import get\_object\_or\_404, render  
from django.urls import reverse  
from django.views import generic

from .models import Choice, Question

class IndexView(generic.ListView):  
template\_name = ‘polls/index.html’  
context\_object\_name = ‘latest\_question\_list’

```
def get_queryset(self):
    """Return the last five published questions."""
    return Question.objects.order_by('-pub_date')[:5]

```

class DetailView(generic.DetailView):  
model = Question  
template\_name = ‘polls/detail.html’

class ResultsView(generic.DetailView):  
model = Question  
template\_name = ‘polls/results.html’

def vote(request, question\_id):  
… # same as above, no changes needed.

This code i have copied from django documentation. Here the question is:  
Using generic views we shouldnt write any function to handel request ie. POST,GET etc. Am i correct!!! ???

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 20, 2020, 12:21pm UTC](https://forum.djangoproject.com/t/not-understanding-with-generic-views/5297/2 "2020-11-20T12:21:16Z")

</div>

Yes, that’s essentially correct, unless you need to modify the standard behavior of the class-provided methods.

That’s the beauty / advantage of the class-based structure. When you inherit a class, you inherit its methods. Since the DetailView already provides a `get` method, you don’t need to.

For a better understanding of how the CBVs work, there are a couple of 3rd party documentation sites that I’ve found to be extremely helpful - The [Classy Class Based View](https://ccbv.co.uk/) site and Brennan Tymrak’s [Django Class-Based Views in Diagrams](https://www.brennantymrak.com/articles/django-class-based-views-diagrams.html) page.
