Opened 11 years ago
Closed 11 years ago
#20733 closed Bug (fixed)
Minor code error in doc page for DetailView
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | 1.5 |
Severity: | Normal | Keywords: | DetailView |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Current (2013-July-11) docs give example myapp/article_detail.html:
<h1>{{ object.headline }}</h1> <p>{{ object.content }}</p> <p>Reporter: {{ object.reporter }}</p> <p>Published: {{ object.pub_date|date }}</p> <p>Date: {{ object.now|date }}</p>
the last line should be
<p>Date: {{ now|date }}</p>
Because views.py only adds 'now' to the context, not as a new attribute of the object being rendered, as below. Currently, object.now displays as 'blank'.
def get_context_data(self, **kwargs): context = super(ArticleDetailView, self).get_context_data(**kwargs) context['now'] = timezone.now() return context
regards - Ian Lewis, Cambridge
Note:
See TracTickets
for help on using tickets.
In f93b2fe7e698a9dd48d839465c75b16013b0f652: