~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to docs/ref/contrib/comments/example.txt

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (4.4.9 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-5rk3p18nyanuhj6g
* SECURITY UPDATE: XSS in CSRF protections. New upstream release
  - CVE-2010-3082
* debian/patches/01_disable_url_verify_regression_tests.diff:
  - updated to disable another test that fails without internet connection
  - patch based on work by Kai Kasurinen and Krzysztof Klimonda
* debian/control: don't Build-Depends on locales-all, which doesn't exist
  in maverick

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. _ref-contrib-comments-example:
2
 
 
3
1
.. highlightlang:: html+django
4
2
 
5
3
===========================================
7
5
===========================================
8
6
 
9
7
Follow the first three steps of the quick start guide in the
10
 
:ref:`documentation <ref-contrib-comments-index>`.
 
8
:doc:`documentation </ref/contrib/comments/index>`.
11
9
 
12
10
Now suppose, you have an app (``blog``) with a model (``Post``)
13
11
to which you want to attach comments. Let us also suppose that
85
83
 
86
84
Since we customize the form in the second method, we make use of another
87
85
tag called :ttag:`comment_form_target`. This tag on rendering gives the URL
88
 
where the comment form is posted. Without any :ref:`customization
89
 
<ref-contrib-comments-custom>`, :ttag:`comment_form_target` evaluates to
 
86
where the comment form is posted. Without any :doc:`customization
 
87
</ref/contrib/comments/custom>`, :ttag:`comment_form_target` evaluates to
90
88
``/comments/post/``. We use this tag in the form's ``action`` attribute.
91
89
 
92
90
The :ttag:`get_comment_form` tag renders a ``form`` for a model instance by
136
134
Feeds
137
135
=====
138
136
 
139
 
Suppose you want to export a :ref:`feed <ref-contrib-syndication>` of the
 
137
Suppose you want to export a :doc:`feed </ref/contrib/syndication>` of the
140
138
latest comments, you can use the in-built :class:`LatestCommentFeed`. Just
141
139
enable it in your project's ``urls.py``:
142
140
 
163
161
 
164
162
Now that we have the comments framework working, we might want to have some
165
163
moderation setup to administer the comments. The comments framework comes
166
 
in-built with :ref:`generic comment moderation
167
 
<ref-contrib-comments-moderation>`. The comment moderation has the following
 
164
in-built with :doc:`generic comment moderation
 
165
</ref/contrib/comments/moderation>`. The comment moderation has the following
168
166
features (all of which or only certain can be enabled):
169
167
 
170
168
  * Enable comments for a particular model instance.
181
179
 
182
180
   from django.contrib.comments.moderation import CommentModerator, moderator
183
181
   from django.db import models
184
 
   
 
182
 
185
183
   class Post(models.Model):
186
184
       title   = models.CharField(max_length = 255)
187
185
       content = models.TextField()
188
186
       posted_date = models.DateTimeField()
189
 
   
 
187
 
190
188
   class PostModerator(CommentModerator):
191
189
       email_notification = True
192
190
       auto_close_field   = 'posted_date'
193
191
       # Close the comments after 7 days.
194
192
       close_after        = 7
195
 
   
 
193
 
196
194
   moderator.register(Post, PostModerator)
197
195
 
198
196
The generic comment moderation also has the facility to remove comments.