Skip to content

Commit

Permalink
Add content_object index to Link
Browse files Browse the repository at this point in the history
  • Loading branch information
david-venhoff authored Nov 25, 2024
1 parent ca223f4 commit 4b72e37
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased

* Add index to Link (David Venhoff, #202)

2.3.0 (2023-12-27)

* Fix encoding of utf-8 domain names (Timo Brembeck, #190)
Expand Down
18 changes: 18 additions & 0 deletions linkcheck/migrations/0011_link_add_content_object_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.3 on 2024-11-25 18:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('linkcheck', '0010_url_add_error_message'),
]

operations = [
migrations.AddIndex(
model_name='link',
index=models.Index(fields=['content_type', 'object_id'], name='content_type_and_object_id'),
),
]
5 changes: 5 additions & 0 deletions linkcheck/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ class Link(models.Model):
text = models.CharField(max_length=256, default='')
ignore = models.BooleanField(default=False)

class Meta:
indexes = [
models.Index(fields=["content_type", "object_id"], name="content_type_and_object_id"),
]

@property
def display_url(self):
# when page /test/ has a anchor link to /test/#anchor, we display it
Expand Down

0 comments on commit 4b72e37

Please sign in to comment.