Skip to content
Snippets Groups Projects
Commit 3aeb1bff authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Optimize requests in Django admin for DataImports

parent e7da8e73
No related branches found
No related tags found
No related merge requests found
from django.contrib import admin
from django.db.models import Max
from enumfields.admin import EnumFieldListFilter
from arkindex.dataimport.models import DataImport, DataFile, Repository, Revision
......@@ -14,6 +15,11 @@ class DataImportAdmin(admin.ModelAdmin):
readonly_fields = ('id', 'workflow', 'state')
inlines = [DataFileInline, ]
def get_queryset(self, *args, **kwargs):
return super().get_queryset(*args, **kwargs) \
.prefetch_related('workflow__tasks') \
.annotate(last_run=Max('workflow__tasks__run'))
class DataFileAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'corpus')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment