diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:29:12 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:29:12 +0000 |
| commit | b9d698e9f238348494703acac67f119de973df25 (patch) | |
| tree | 502a676a1997592f49296865aa91c411046173cf /docs | |
| parent | f6c519e2b919cddc438f6ff52f2b4d7ef8248042 (diff) | |
Fixed #10285 - Added render_comment_list template tag to comments app. Thanks Kyle Fuller for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12082 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/comments/example.txt | 15 | ||||
| -rw-r--r-- | docs/ref/contrib/comments/index.txt | 27 |
2 files changed, 39 insertions, 3 deletions
diff --git a/docs/ref/contrib/comments/example.txt b/docs/ref/contrib/comments/example.txt index 626e8b4a95..e9445353ca 100644 --- a/docs/ref/contrib/comments/example.txt +++ b/docs/ref/contrib/comments/example.txt @@ -39,6 +39,18 @@ available in the context, then you can refer to it directly:: {% get_comment_count for entry as comment_count %} <p>{{ comment_count }} comments have been posted.</p> +Next, we can use the :ttag:`render_comment_list` tag, to render all comments +to the given instance (``entry``) by using the ``comments/list.html`` template. + + {% render_comment_list for entry %} + +Django will will look for the ``list.html`` under the following directories +(for our example):: + + comments/blog/post/list.html + comments/blog/list.html + comments/list.html + To get a list of comments, we make use of the :ttag:`get_comment_list` tag. This tag's usage is very similar to the :ttag:`get_comment_count` tag. We need to remember that the :ttag:`get_comment_list` returns a list of comments @@ -58,7 +70,7 @@ display the comments template available under your ``comments/form.html``. The other method gives you a chance to customize the form. The first method makes use of the :ttag:`render_comment_form` tag. It's usage -too is similar to the other two tags we have discussed above:: +too is similar to the other three tags we have discussed above:: {% render_comment_form for entry %} @@ -74,6 +86,7 @@ tag called :ttag:`comment_form_target`. This tag on rendering gives the URL where the comment form is posted. Without any :ref:`customization <ref-contrib-comments-custom>`, :ttag:`comment_form_target` evaluates to ``/comments/post/``. We use this tag in the form's ``action`` attribute. + The :ttag:`get_comment_form` tag renders a ``form`` for a model instance by creating a context variable. One can iterate over the ``form`` object to get individual fields. This gives you fine-grain control over the form:: diff --git a/docs/ref/contrib/comments/index.txt b/docs/ref/contrib/comments/index.txt index f66d14d0c4..9f53f06299 100644 --- a/docs/ref/contrib/comments/index.txt +++ b/docs/ref/contrib/comments/index.txt @@ -84,11 +84,34 @@ different ways you can specify which object to attach to: In the above, ``blog.entry`` is the app label and (lower-cased) model name of the model class. -.. templatetag:: get_comment_list - Displaying comments ------------------- +To display a list of comments, you can use the template tags +:ttag:`render_comment_list` or :ttag:`get_comment_list`. + +.. templatetag:: render_comment_list + +Quickly rendering a comment list +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The easiest way to display a list of comments for some object is by using +:ttag:`render_comment_list`:: + + {% render_comment_list for [object] %} + +For example:: + + {% render_comment_list for event %} + +This will render comments using a template named ``comments/list.html``, a +default version of which is included with Django. + +.. templatetag:: get_comment_list + +Rendering a custom comment list +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + To get the list of comments for some object, use :ttag:`get_comment_list`:: {% get_comment_list for [object] as [varname] %} |
