File: forms.txt

package info (click to toggle)
python-django 1.7.11-1%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 45,624 kB
  • sloc: python: 171,189; xml: 713; sh: 203; makefile: 199; sql: 11
file content (58 lines) | stat: -rw-r--r-- 2,228 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
====================
Comment form classes
====================

.. module:: django.contrib.comments.forms
   :synopsis: Forms for dealing with the built-in comment model.

.. warning::

    Django's comment framework has been deprecated and is no longer supported.
    Most users will be better served with a custom solution, or a hosted
    product like Disqus__.

    The code formerly known as ``django.contrib.comments`` is `still available
    in an external repository`__.

    __ https://disqus.com/
    __ https://github.com/django/django-contrib-comments

The ``django.contrib.comments.forms`` module contains a handful of forms
you'll use when writing custom views dealing with comments, or when writing
:doc:`custom comment apps </ref/contrib/comments/custom>`.

.. class:: CommentForm

   The main comment form representing the standard, built-in way of handling
   submitted comments. This is the class used by all the views
   :mod:`django.contrib.comments` to handle submitted comments.

   If you want to build custom views that are similar to Django's built-in
   comment handling views, you'll probably want to use this form.

Abstract comment forms for custom comment apps
----------------------------------------------

If you're building a :doc:`custom comment app </ref/contrib/comments/custom>`,
you might want to replace *some* of the form logic but still rely on parts of
the existing form.

:class:`CommentForm` is actually composed of a couple of abstract base class
forms that you can subclass to reuse pieces of the form handling logic:

.. class:: CommentSecurityForm

   Handles the anti-spoofing protection aspects of the comment form handling.

   This class contains the ``content_type`` and ``object_pk`` fields pointing
   to the object the comment is attached to, along with a ``timestamp`` and a
   ``security_hash`` of all the form data. Together, the timestamp and the
   security hash ensure that spammers can't "replay" form submissions and
   flood you with comments.

.. class:: CommentDetailsForm

   Handles the details of the comment itself.

   This class contains the ``name``, ``email``, ``url``, and the ``comment``
   field itself, along with the associated validation logic.