Commit 153f2af1 authored by Mathieu Courcelles's avatar Mathieu Courcelles

Adds prefetch related to queryset

parent 25b7d6ce
Pipeline #14986939 passed with stage
in 2 minutes and 22 seconds
......@@ -50,15 +50,15 @@ from .parser.mgf_parser import MGFParser
from .parser.parser_generic import parser_generic
from .pdb_structure import (compute_cl_distance,
retrievePDBfile
)
retrievePDBfile
)
from .queryset_operation import (dataset_set_2_clpeptide_set,
clpeptide_set_2_protein_set,
clpeptide_set_2_quantificationPkString
)
clpeptide_set_2_protein_set,
clpeptide_set_2_quantificationPkString
)
from .views import (jsmol_view,
xiNET_view
)
xiNET_view
)
def wrapString(text, length):
......@@ -450,7 +450,6 @@ class CLPeptideAdmin(admin.ModelAdmin):
cache = caches['default']
cache.set(f'query_{random}', queryset.query, 300)
selected_action = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)[0]
form = PDBQuantForm(initial={'quant_pk': quant_pk,
'_selected_action': selected_action})
......@@ -598,6 +597,8 @@ class DatasetAdminMixin(object):
date_hierarchy = 'creation_date'
list_per_page = 25
# Test code for intermediate page of compareRunIds_csv
# Modified from http://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/
class CompareForm(forms.Form):
......@@ -962,6 +963,12 @@ class RawDatasetAdmin(DatasetAdminMixin, admin.ModelAdmin):
search_fields = ('name', 'file', 'description')
def get_queryset(self, request):
queryset = super().get_queryset(request)
queryset = queryset.prefetch_related('cross_linker', 'fasta_db',
'search_algorithm')
return queryset
def get_readonly_fields(self, request, obj=None):
"""
This method sets some fields read only after dataset creation and
......@@ -1012,6 +1019,13 @@ class ProcessedDatasetAdmin(DatasetAdminMixin, admin.ModelAdmin):
search_fields = ('name', 'datasets__name', 'description',
'clpeptidefilter__name')
def get_queryset(self, request):
queryset = super().get_queryset(request)
queryset = queryset.prefetch_related('clpeptidefilter',
'cross_linker', 'fasta_db',
'search_algorithm')
return queryset
def getDataset(self, obj):
"""
Returns HTML links to all dataset selected to create this processed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment