Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1271 from batisteo/ticket-20565

Fixed #20565 -- Added template examples for GCBV.
  • Loading branch information...
commit f6567578887b7cc4efb0006ac4a3a5ba7a1c2cc7 2 parents 3873725 + 8154594
Marc Tamlyn authored June 14, 2013
24  docs/ref/class-based-views/generic-date-based.txt
@@ -63,7 +63,7 @@ ArchiveIndexView
63 63
       month or day using the attribute ``date_list_period``. This also applies
64 64
       to all subclass views.
65 65
 
66  
-    **Example views.py**::
  66
+    **Example myapp/views.py**::
67 67
 
68 68
         from django.conf.urls import patterns, url
69 69
         from django.views.generic.dates import ArchiveIndexView
@@ -160,7 +160,7 @@ YearArchiveView
160 160
 
161 161
     * Uses a default ``template_name_suffix`` of ``_archive_year``.
162 162
 
163  
-    **Example views.py**::
  163
+    **Example myapp/views.py**::
164 164
 
165 165
         from django.views.generic.dates import YearArchiveView
166 166
 
@@ -172,7 +172,7 @@ YearArchiveView
172 172
             make_object_list = True
173 173
             allow_future = True
174 174
 
175  
-    **Example urls.py**::
  175
+    **Example myapp/urls.py**::
176 176
 
177 177
         from django.conf.urls import patterns, url
178 178
 
@@ -255,7 +255,7 @@ MonthArchiveView
255 255
 
256 256
     * Uses a default ``template_name_suffix`` of ``_archive_month``.
257 257
 
258  
-    **Example views.py**::
  258
+    **Example myapp/views.py**::
259 259
 
260 260
         from django.views.generic.dates import MonthArchiveView
261 261
 
@@ -267,7 +267,7 @@ MonthArchiveView
267 267
             make_object_list = True
268 268
             allow_future = True
269 269
 
270  
-    **Example urls.py**::
  270
+    **Example myapp/urls.py**::
271 271
 
272 272
         from django.conf.urls import patterns, url
273 273
 
@@ -348,7 +348,7 @@ WeekArchiveView
348 348
 
349 349
     * Uses a default ``template_name_suffix`` of ``_archive_week``.
350 350
 
351  
-    **Example views.py**::
  351
+    **Example myapp/views.py**::
352 352
 
353 353
         from django.views.generic.dates import WeekArchiveView
354 354
 
@@ -361,7 +361,7 @@ WeekArchiveView
361 361
             week_format = "%W"
362 362
             allow_future = True
363 363
 
364  
-    **Example urls.py**::
  364
+    **Example myapp/urls.py**::
365 365
 
366 366
         from django.conf.urls import patterns, url
367 367
 
@@ -463,7 +463,7 @@ DayArchiveView
463 463
 
464 464
     * Uses a default ``template_name_suffix`` of ``_archive_day``.
465 465
 
466  
-    **Example views.py**::
  466
+    **Example myapp/views.py**::
467 467
 
468 468
         from django.views.generic.dates import DayArchiveView
469 469
 
@@ -475,7 +475,7 @@ DayArchiveView
475 475
             make_object_list = True
476 476
             allow_future = True
477 477
 
478  
-    **Example urls.py**::
  478
+    **Example myapp/urls.py**::
479 479
 
480 480
         from django.conf.urls import patterns, url
481 481
 
@@ -537,7 +537,7 @@ TodayArchiveView
537 537
 
538 538
     * Uses a default ``template_name_suffix`` of ``_archive_today``.
539 539
 
540  
-    **Example views.py**::
  540
+    **Example myapp/views.py**::
541 541
 
542 542
         from django.views.generic.dates import TodayArchiveView
543 543
 
@@ -549,7 +549,7 @@ TodayArchiveView
549 549
             make_object_list = True
550 550
             allow_future = True
551 551
 
552  
-    **Example urls.py**::
  552
+    **Example myapp/urls.py**::
553 553
 
554 554
         from django.conf.urls import patterns, url
555 555
 
@@ -599,7 +599,7 @@ DateDetailView
599 599
 
600 600
     * Uses a default ``template_name_suffix`` of ``_detail``.
601 601
 
602  
-    **Example urls.py**::
  602
+    **Example myapp/urls.py**::
603 603
 
604 604
         from django.conf.urls import patterns, url
605 605
         from django.views.generic.dates import DateDetailView
29  docs/ref/class-based-views/generic-display.txt
@@ -36,7 +36,7 @@ DetailView
36 36
     9. ``get()``
37 37
     10. :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response()`
38 38
 
39  
-    **Example views.py**::
  39
+    **Example myapp/views.py**::
40 40
 
41 41
         from django.views.generic.detail import DetailView
42 42
         from django.utils import timezone
@@ -52,7 +52,7 @@ DetailView
52 52
                 context['now'] = timezone.now()
53 53
                 return context
54 54
 
55  
-    **Example urls.py**::
  55
+    **Example myapp/urls.py**::
56 56
 
57 57
         from django.conf.urls import patterns, url
58 58
 
@@ -62,6 +62,16 @@ DetailView
62 62
             url(r'^(?P<slug>[-_\w]+)/$', ArticleDetailView.as_view(), name='article-detail'),
63 63
         )
64 64
 
  65
+    **Example myapp/article_detail.html**:
  66
+
  67
+    .. code-block:: html+django
  68
+
  69
+        <h1>{{ object.headline }}</h1>
  70
+        <p>{{ object.content }}</p>
  71
+        <p>Reporter: {{ object.reporter }}</p>
  72
+        <p>Published: {{ object.pub_date|date }}</p>
  73
+        <p>Date: {{ object.now|date }}</p>
  74
+
65 75
 ListView
66 76
 --------
67 77
 
@@ -111,7 +121,7 @@ ListView
111 121
                 context['now'] = timezone.now()
112 122
                 return context
113 123
 
114  
-    **Example urls.py**::
  124
+    **Example myapp/urls.py**::
115 125
 
116 126
         from django.conf.urls import patterns, url
117 127
 
@@ -121,6 +131,19 @@ ListView
121 131
             url(r'^$', ArticleListView.as_view(), name='article-list'),
122 132
         )
123 133
 
  134
+    **Example myapp/article_list.html**:
  135
+
  136
+    .. code-block:: html+django
  137
+
  138
+        <h1>Articles</h1>
  139
+        <ul>
  140
+        {% for article in object_list %}
  141
+            <li>{{ article.pub_date|date }} - {{ article.headline }}</li>
  142
+        {% empty %}
  143
+            <li>No articles yet.</li>
  144
+        {% endfor %}
  145
+        </ul>
  146
+
124 147
 .. class:: django.views.generic.list.BaseListView
125 148
 
126 149
     A base view for displaying a list of objects. It is not intended to be used
49  docs/ref/class-based-views/generic-editing.txt
@@ -42,7 +42,7 @@ FormView
42 42
     * :class:`django.views.generic.edit.ProcessFormView`
43 43
     * :class:`django.views.generic.base.View`
44 44
 
45  
-    **Example forms.py**::
  45
+    **Example myapp/forms.py**::
46 46
 
47 47
         from django import forms
48 48
 
@@ -54,7 +54,7 @@ FormView
54 54
                 # send email using the self.cleaned_data dictionary
55 55
                 pass
56 56
 
57  
-    **Example views.py**::
  57
+    **Example myapp/views.py**::
58 58
 
59 59
         from myapp.forms import ContactForm
60 60
         from django.views.generic.edit import FormView
@@ -70,6 +70,16 @@ FormView
70 70
                 form.send_email()
71 71
                 return super(ContactView, self).form_valid(form)
72 72
 
  73
+    **Example myapp/contact.html**:
  74
+
  75
+    .. code-block:: html+django
  76
+
  77
+        <form action="" method="post">{% csrf_token %}
  78
+            {{ form.as_p }}
  79
+            <input type="submit" value="Send message" />
  80
+        </form>
  81
+
  82
+
73 83
 CreateView
74 84
 ----------
75 85
 
@@ -101,7 +111,7 @@ CreateView
101 111
         creating objects for the example ``Author`` model would cause the
102 112
         default ``template_name`` to be ``'myapp/author_create_form.html'``.
103 113
 
104  
-    **Example views.py**::
  114
+    **Example myapp/views.py**::
105 115
 
106 116
         from django.views.generic.edit import CreateView
107 117
         from myapp.models import Author
@@ -110,6 +120,15 @@ CreateView
110 120
             model = Author
111 121
             fields = ['name']
112 122
 
  123
+    **Example myapp/author_form.html**:
  124
+
  125
+    .. code-block:: html+django
  126
+
  127
+        <form action="" method="post">{% csrf_token %}
  128
+            {{ form.as_p }}
  129
+            <input type="submit" value="Create" />
  130
+        </form>
  131
+
113 132
 UpdateView
114 133
 ----------
115 134
 
@@ -143,7 +162,7 @@ UpdateView
143 162
         updating objects for the example ``Author`` model would cause the
144 163
         default ``template_name`` to be ``'myapp/author_update_form.html'``.
145 164
 
146  
-    **Example views.py**::
  165
+    **Example myapp/views.py**::
147 166
 
148 167
         from django.views.generic.edit import UpdateView
149 168
         from myapp.models import Author
@@ -151,6 +170,16 @@ UpdateView
151 170
         class AuthorUpdate(UpdateView):
152 171
             model = Author
153 172
             fields = ['name']
  173
+            template_name_suffix = '_update_form'
  174
+
  175
+    **Example myapp/author_update_form.html**:
  176
+
  177
+    .. code-block:: html+django
  178
+
  179
+        <form action="" method="post">{% csrf_token %}
  180
+            {{ form.as_p }}
  181
+            <input type="submit" value="Update" />
  182
+        </form>
154 183
 
155 184
 DeleteView
156 185
 ----------
@@ -184,8 +213,7 @@ DeleteView
184 213
         deleting objects for the example ``Author`` model would cause the
185 214
         default ``template_name`` to be ``'myapp/author_check_delete.html'``.
186 215
 
187  
-
188  
-    **Example views.py**::
  216
+    **Example myapp/views.py**::
189 217
 
190 218
         from django.views.generic.edit import DeleteView
191 219
         from django.core.urlresolvers import reverse_lazy
@@ -194,3 +222,12 @@ DeleteView
194 222
         class AuthorDelete(DeleteView):
195 223
             model = Author
196 224
             success_url = reverse_lazy('author-list')
  225
+
  226
+    **Example myapp/author_confirm_delete.html**:
  227
+
  228
+    .. code-block:: html+django
  229
+
  230
+        <form action="" method="post">{% csrf_token %}
  231
+            <p>Are you sure you want to delete "{{ object }}"?</p>
  232
+            <input type="submit" value="Confirm" />
  233
+        </form>

0 notes on commit f656757

Please sign in to comment.
Something went wrong with that request. Please try again.