Code

Opened 17 months ago

Closed 17 months ago

Last modified 17 months 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:
Needs tests: Patch needs improvement:
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"

Attachments (0)

Change History (2)

comment:1 Changed 17 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In d009ffe436410f6935798d910b0e489d53411dfa:

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

comment:2 Changed 17 months ago by Tim Graham <timograham@…>

In ed381bd922faa1379f1021f2a3dd57fe8a5163b2:

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

Backport of d009ffe436 from master

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.