Added index on AbstractImage.created_at

Fixes #1598

Speeds up image index/chooser when many images exist in the site
pull/1623/head
Karl Hobley 2015-08-19 12:15:40 +01:00
rodzic a8a7344927
commit 9bd04efd05
3 zmienionych plików z 44 dodań i 1 usunięć

Wyświetl plik

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('tests', '0006_image_file_size'),
]
operations = [
migrations.AlterField(
model_name='customimagewithadminformfields',
name='created_at',
field=models.DateTimeField(db_index=True, verbose_name='Created at', auto_now_add=True),
),
migrations.AlterField(
model_name='customimagewithoutadminformfields',
name='created_at',
field=models.DateTimeField(db_index=True, verbose_name='Created at', auto_now_add=True),
),
]

Wyświetl plik

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0007_image_file_size'),
]
operations = [
migrations.AlterField(
model_name='image',
name='created_at',
field=models.DateTimeField(db_index=True, verbose_name='Created at', auto_now_add=True),
),
]

Wyświetl plik

@ -63,7 +63,7 @@ class AbstractImage(models.Model, TagSearchable):
file = models.ImageField(verbose_name=_('File'), upload_to=get_upload_to, width_field='width', height_field='height')
width = models.IntegerField(verbose_name=_('Width'), editable=False)
height = models.IntegerField(verbose_name=_('Height'), editable=False)
created_at = models.DateTimeField(verbose_name=_('Created at'), auto_now_add=True)
created_at = models.DateTimeField(verbose_name=_('Created at'), auto_now_add=True, db_index=True)
uploaded_by_user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('Uploaded by user'), null=True, blank=True, editable=False)
tags = TaggableManager(help_text=None, blank=True, verbose_name=_('Tags'))