#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: | dev |
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 |
Description
The page at https://docs.djangoproject.com/en/dev/topics/class-based-views/intro/ 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"
In d009ffe436410f6935798d910b0e489d53411dfa: