Code

Opened 13 months ago

Closed 13 months ago

Last modified 13 months ago

#20565 closed New feature (fixed)

Generic view descriptions should give template examples

Reported by: david.reitter@… Owned by: batisteo
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: bmispelon@…, batisteo Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When reading the docs for generic views, I wonder what the templates should like like.

It does not seem like standard templates are provided (why not?), but as a minimum, the documentation should give an example of a template for each view class.

The template variables are idiosyncratic w.r.t. the view class, e.g., the ListView defines 'object_list' as a variable. So why not give this template example:

{% block content %}
<h1>Exams</h1>
    <table>
        {% for o in object_list %}
           <tr><td>{{ o }}</td><td><a href="{% url 'exam_update' o.id %}">edit</a>&nbsp;&nbsp;<a href="{% url 'exam_delete' o.id %}">del</a></td></tr>
        {% endfor %}
    </table>
{% endblock %}

Right now, I am looking for how to correctly implement the delete confirmation template.

https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-editing/#django.views.generic.edit.DeleteView

Attachments (0)

Change History (6)

comment:1 Changed 13 months ago by bmispelon

  • Cc bmispelon@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature

Seeing as we're already providing an example views.py and urls.py for most views, I think it makes sense to include an example template when it makes sense.

The only example template I could find was in https://docs.djangoproject.com/en/1.5/topics/class-based-views/generic-display/#generic-views-of-objects.

comment:2 Changed 13 months ago by batisteo

  • Cc batisteo added
  • Owner changed from nobody to batisteo
  • Status changed from new to assigned

comment:4 Changed 13 months ago by batisteo

  • Has patch set

comment:5 Changed 13 months ago by Baptiste Darthenay <baptiste+github@…>

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

In 81545940c68de0d1235a2fb50e61b8619f17a3e3:

Fixed #20565 -- Added template examples for GCBV.

Thanks to David Reitter for the report,
and to Marc Tamlyn and Baptiste Mispelon for the review.

comment:6 Changed 13 months ago by Marc Tamlyn <marc.tamlyn@…>

In f6567578887b7cc4efb0006ac4a3a5ba7a1c2cc7:

Merge pull request #1271 from batisteo/ticket-20565

Fixed #20565 -- Added template examples for GCBV.

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.