diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt
index 22a204d..c83559f 100644
a
|
b
|
TemplateResponseMixin
|
81 | 81 | The response class to be returned by ``render_to_response`` method. |
82 | 82 | Default is |
83 | 83 | :class:`TemplateResponse <django.template.response.TemplateResponse>`. |
84 | | The template and context of TemplateResponse instances can be |
| 84 | The template and context of ``TemplateResponse`` instances can be |
85 | 85 | altered later (e.g. in |
86 | 86 | :ref:`template response middleware <template-response-middleware>`). |
87 | 87 | |
88 | | Create TemplateResponse subclass and pass set it to |
89 | | ``template_response_class`` if you need custom template loading or |
90 | | custom context object instantiation. |
| 88 | If you need custom template loading or custom context object |
| 89 | instantiation, create a ``TemplateResponse`` subclass and assign it to |
| 90 | ``response_class``. |
91 | 91 | |
92 | 92 | .. method:: render_to_response(context, **response_kwargs) |
93 | 93 | |
94 | | Returns a ``self.template_response_class`` instance. |
| 94 | Returns a ``self.response_class`` instance. |
95 | 95 | |
96 | 96 | If any keyword arguments are provided, they will be |
97 | | passed to the constructor of the response instance. |
| 97 | passed to the constructor of the response class. |
98 | 98 | |
99 | 99 | Calls :meth:`~TemplateResponseMixin.get_template_names()` to obtain the |
100 | 100 | list of template names that will be searched looking for an existent |
diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt
index c59151a..9328d23 100644
a
|
b
|
so we can just subclass it, and override the template name::
|
71 | 71 | template_name = "about.html" |
72 | 72 | |
73 | 73 | Then, we just need to add this new view into our URLconf. As the class-based |
74 | | views themselves are classes, we point the URL to the as_view class method |
| 74 | views themselves are classes, we point the URL to the ``as_view`` class method |
75 | 75 | instead, which is the entry point for class-based views:: |
76 | 76 | |
77 | 77 | # urls.py |
… |
… |
instead, which is the entry point for class-based views::
|
83 | 83 | ) |
84 | 84 | |
85 | 85 | Alternatively, if you're only changing a few simple attributes on a |
86 | | class-based view, you can simply pass the new attributes into the as_view |
| 86 | class-based view, you can simply pass the new attributes into the ``as_view`` |
87 | 87 | method call itself:: |
88 | 88 | |
89 | 89 | from django.conf.urls.defaults import * |
… |
… |
be using these models::
|
121 | 121 | country = models.CharField(max_length=50) |
122 | 122 | website = models.URLField() |
123 | 123 | |
124 | | def __unicode__(self): |
125 | | return self.name |
126 | | |
127 | 124 | class Meta: |
128 | 125 | ordering = ["-name"] |
129 | 126 | |
| 127 | def __unicode__(self): |
| 128 | return self.name |
| 129 | |
130 | 130 | class Book(models.Model): |
131 | 131 | title = models.CharField(max_length=100) |
132 | 132 | authors = models.ManyToManyField('Author') |
… |
… |
all the publishers in a variable named ``object_list``. While this
|
211 | 211 | works just fine, it isn't all that "friendly" to template authors: |
212 | 212 | they have to "just know" that they're dealing with publishers here. |
213 | 213 | |
214 | | Well, if you're dealing with a Django object, this is already done for |
| 214 | Well, if you're dealing with a Model object, this is already done for |
215 | 215 | you. When you are dealing with an object or queryset, Django is able |
216 | 216 | to populate the context using the verbose name (or the plural verbose |
217 | 217 | name, in the case of a list of objects) of the object being displayed. |
… |
… |
key in the URL. Earlier we hard-coded the publisher's name in the URLconf, but
|
353 | 353 | what if we wanted to write a view that displayed all the books by some arbitrary |
354 | 354 | publisher? |
355 | 355 | |
356 | | Handily, the ListView has a |
| 356 | Handily, the ``ListView`` has a |
357 | 357 | :meth:`~django.views.generic.detail.ListView.get_queryset` method we can |
358 | 358 | override. Previously, it has just been returning the value of the ``queryset`` |
359 | 359 | attribute, but now we can add more logic. |
… |
… |
custom view:
|
444 | 444 | **(r'^authors/(?P<pk>\\d+)/$', AuthorDetailView.as_view()),** |
445 | 445 | ) |
446 | 446 | |
447 | | Then we'd write our new view - ``get_object`` is the method that retrieves the |
448 | | object, so we simply override it and wrap the call:: |
| 447 | Then we'd write our new view -- ``get_object`` is the method that retrieves the |
| 448 | object -- so we simply override it and wrap the call:: |
449 | 449 | |
450 | 450 | import datetime |
451 | 451 | from books.models import Author |
… |
… |
object, so we simply override it and wrap the call::
|
473 | 473 | .. note:: |
474 | 474 | |
475 | 475 | The URLconf here uses the named group ``pk`` - this name is the default |
476 | | name that DetailView uses to find the value of the primary key used to |
| 476 | name that ``DetailView`` uses to find the value of the primary key used to |
477 | 477 | filter the queryset. |
478 | 478 | |
479 | 479 | If you want to change it, you'll need to do your own ``get()`` call |
… |
… |
login protection.
|
613 | 613 | ``method_decorator`` passes ``*args`` and ``**kwargs`` |
614 | 614 | as parameters to the decorated method on the class. If your method |
615 | 615 | does not accept a compatible set of parameters it will raise a |
616 | | ``TypeError`` exception. |
617 | | No newline at end of file |
| 616 | ``TypeError`` exception. |