Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#19937 closed Bug (fixed)

Small bug in a documentation code example (Introduction to Class-based views)

Reported by: anonymous Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The page at says:

The first is the standard Python way of subclassing and overriding attributes and
methods in the subclass. So that if your parent class had an attribute greeting
like this:

from django.http import HttpResponse
from django.views.base import View

class GreetingView(View):

greeting = "Good Day"

def get(self, request):

return HttpResponse(self.greeting)

You can override that in a subclass:

class MorningGreetingView(MyView):

greeting = "Morning to ya"

The superclass of the last definition is wrong. Correct definition would be:

class MorningGreetingView(GreetingView):
    greeting = "Morning to ya"

Change History (2)

comment:1 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In d009ffe436410f6935798d910b0e489d53411dfa:

Fixed #19937 - Typo in class-based views intro.

comment:2 Changed 5 years ago by Tim Graham <timograham@…>

In ed381bd922faa1379f1021f2a3dd57fe8a5163b2:

[1.5.x] Fixed #19937 - Typo in class-based views intro.

Backport of d009ffe436 from master

Note: See TracTickets for help on using tickets.
Back to Top