File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ Unreleased
8
8
9
9
* Dropped support for Django 1.11, 2.0, and 2.1.
10
10
* Added the ``delete_stale_comments `` management command.
11
+ * Added db_index to ``object_pk `` and ``is_removed `` fields.
12
+ * Altered ``object_pk `` from ``TextField `` to ``CharField(max_length=64) ``
13
+ so that the field can be indexed on MySQL, too. **Warning: ** if you attach
14
+ comments to objects whose primary key is serialized to more than 64
15
+ characters, you should provide a custom Comment model
16
+ (more about that in the documentation) with an appropriate
17
+ ``object_pk `` field.
18
+
11
19
12
20
2.0.0 (2020-12-20)
13
21
------------------
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class BaseCommentAbstractModel(models.Model):
23
23
verbose_name = _ ('content type' ),
24
24
related_name = "content_type_set_for_%(class)s" ,
25
25
on_delete = models .CASCADE )
26
- object_pk = models .TextField (_ ('object ID' ))
26
+ object_pk = models .CharField (_ ('object ID' ), db_index = True , max_length = 64 )
27
27
content_object = GenericForeignKey (ct_field = "content_type" , fk_field = "object_pk" )
28
28
29
29
# Metadata about the comment
@@ -65,7 +65,7 @@ class CommentAbstractModel(BaseCommentAbstractModel):
65
65
is_public = models .BooleanField (_ ('is public' ), default = True ,
66
66
help_text = _ ('Uncheck this box to make the comment effectively '
67
67
'disappear from the site.' ))
68
- is_removed = models .BooleanField (_ ('is removed' ), default = False ,
68
+ is_removed = models .BooleanField (_ ('is removed' ), default = False , db_index = True ,
69
69
help_text = _ ('Check this box if the comment is inappropriate. '
70
70
'A "This comment has been removed" message will '
71
71
'be displayed instead.' ))
Original file line number Diff line number Diff line change
1
+ from django .db import migrations , models
2
+
3
+
4
+ class Migration (migrations .Migration ):
5
+
6
+ dependencies = [
7
+ ('django_comments' , '0003_add_submit_date_index' ),
8
+ ]
9
+
10
+ operations = [
11
+ migrations .AlterField (
12
+ model_name = 'comment' ,
13
+ name = 'is_removed' ,
14
+ field = models .BooleanField (
15
+ db_index = True , default = False ,
16
+ help_text = 'Check this box if the comment is inappropriate. '
17
+ 'A "This comment has been removed" message will be displayed instead.' ,
18
+ verbose_name = 'is removed' ),
19
+ ),
20
+ migrations .AlterField (
21
+ model_name = 'comment' ,
22
+ name = 'object_pk' ,
23
+ field = models .CharField (max_length = 64 , db_index = True , verbose_name = 'object ID' ),
24
+ ),
25
+ ]
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ The comment models
28
28
29
29
.. attribute:: object_pk
30
30
31
- A :class:`~django.db.models.TextField ` containing the primary
32
- key of the object the comment is attached to.
31
+ A :class:`~django.db.models.CharField ` containing the primary
32
+ key of the object the comment is attached to. ``max_length=64``.
33
33
34
34
.. attribute:: site
35
35
You can’t perform that action at this time.
0 commit comments