models.txt 2.31 KB
Newer Older
1 2 3 4 5 6
===========================
The built-in comment models
===========================

.. module:: django.contrib.comments.models
   :synopsis: The built-in comment models
7

8 9 10
.. class:: Comment

    Django's built-in comment model. Has the following fields:
11

12
    .. attribute:: content_object
13

14 15 16
        A :class:`~django.contrib.contettypes.generic.GenericForeignKey`
        attribute pointing to the object the comment is attached to. You can use
        this to get at the related object (i.e. ``my_comment.content_object``).
17

18 19 20 21
        Since this field is a
        :class:`~django.contrib.contettypes.generic.GenericForeignKey`, it's
        actually syntactic sugar on top of two underlying attributes, described
        below.
22

23
    .. attribute:: content_type
24

25 26 27
        A :class:`~django.db.models.ForeignKey` to
        :class:`~django.contrib.contenttypes.models.ContentType`; this is the
        type of the object the comment is attached to.
28

29
    .. attribute:: object_pk
30

31 32
        A :class:`~django.db.models.TextField` containing the primary
        key of the object the comment is attached to.
33

34
    .. attribute:: site
35

36 37 38
        A :class:`~django.db.models.ForeignKey` to the
        :class:`~django.contrib.sites.models.Site` on which the comment was
        posted.
39

40
    .. attribute:: user
41

42 43 44
        A :class:`~django.db.models.ForeignKey` to the
        :class:`~django.contrib.auth.models.User` who posted the comment.
        May be blank if the comment was posted by an unauthenticated user.
45

46
    .. attribute:: user_name
47

48
        The name of the user who posted the comment.
49

50
    .. attribute:: user_email
51

52
        The email of the user who posted the comment.
53

54
    .. attribute:: user_url
55

56
        The URL entered by the person who posted the comment.
57

58
    .. attribute:: comment
59

60
        The actual content of the comment itself.
61

62
    .. attribute:: submit_date
63

64
        The date the comment was submitted.
65

66
    .. attribute:: ip_address
67

68
        The IP address of the user posting the comment.
69

70
    .. attribute:: is_public
71

72
        ``False`` if the comment is in moderation (see
73
        :doc:`/ref/contrib/comments/moderation`); If ``True``, the comment will
74
        be displayed on the site.
75

76
    .. attribute:: is_removed
77

78 79
        ``True`` if the comment was removed. Used to keep track of removed
        comments instead of just deleting them.
80