forms.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ====================
  2. Comment form classes
  3. ====================
  4. .. module:: django.contrib.comments.forms
  5. :synopsis: Forms for dealing with the built-in comment model.
  6. .. warning::
  7. Django's comment framework has been deprecated and is no longer supported.
  8. Most users will be better served with a custom solution, or a hosted
  9. product like Disqus__.
  10. The code formerly known as ``django.contrib.comments`` is `still available
  11. in an external repository`__.
  12. __ https://disqus.com/
  13. __ https://github.com/django/django-contrib-comments
  14. The ``django.contrib.comments.forms`` module contains a handful of forms
  15. you'll use when writing custom views dealing with comments, or when writing
  16. :doc:`custom comment apps </ref/contrib/comments/custom>`.
  17. .. class:: CommentForm
  18. The main comment form representing the standard, built-in way of handling
  19. submitted comments. This is the class used by all the views
  20. :mod:`django.contrib.comments` to handle submitted comments.
  21. If you want to build custom views that are similar to Django's built-in
  22. comment handling views, you'll probably want to use this form.
  23. Abstract comment forms for custom comment apps
  24. ----------------------------------------------
  25. If you're building a :doc:`custom comment app </ref/contrib/comments/custom>`,
  26. you might want to replace *some* of the form logic but still rely on parts of
  27. the existing form.
  28. :class:`CommentForm` is actually composed of a couple of abstract base class
  29. forms that you can subclass to reuse pieces of the form handling logic:
  30. .. class:: CommentSecurityForm
  31. Handles the anti-spoofing protection aspects of the comment form handling.
  32. This class contains the ``content_type`` and ``object_pk`` fields pointing
  33. to the object the comment is attached to, along with a ``timestamp`` and a
  34. ``security_hash`` of all the form data. Together, the timestamp and the
  35. security hash ensure that spammers can't "replay" form submissions and
  36. flood you with comments.
  37. .. class:: CommentDetailsForm
  38. Handles the details of the comment itself.
  39. This class contains the ``name``, ``email``, ``url``, and the ``comment``
  40. field itself, along with the associated validation logic.