Code

Opened 6 months ago

Closed 6 months ago

#21336 closed Uncategorized (worksforme)

ListView doesnt work with context_object_name

Reported by: anamsarfraz@… Owned by: nobody
Component: Documentation Version: 1.5
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

I read in the documentation that the template_object_name has been replaced with context_object_name. But when I try to get the ListView of a model, it doesnt work with context_object_name but works with template_object_name. I also tried the DetailView. In DetailView, it seems that replacement has been done because I got an error when I tried to use template_object_name but DetailView worked as expected with context_object_name.

Attachments (0)

Change History (1)

comment:1 Changed 6 months ago by alasdair

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

template_object_name was definitely replaced with context_object_name when changing from function to class-based generic views.

If you grep the source code for 1.5, you can see that template_object_name does not appear any where in the code:

[django]$ git checkout 1.5
HEAD is now at b170c07... [1.5.x] Correct final element of version tuple.
[django]$ git grep template_object_name
[django]$ 

Note the warning in the docs that the template_object_name was appended with the suffix '_list', but in a class-based ListView, the context_object_name is used verbatim.

If you need further help please see https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels

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.