Unverified Commit a60ecdf8 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Speed up CommitteeInline

Prefetch the users in the CommitteeInline
parent 1732593e
from django.contrib import admin
from django.forms import ModelForm
from activemembers.forms import CommitteeMembershipForm
from members.models import Member
from utils.translation import TranslatedModelAdmin
from . import models
class CommitteeMembershipInlineForm(ModelForm):
"""
Form for the Committee Membership inline
Doesn't do anything fancy, but we need it for speed.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Get the related fields in advance
self.fields['member'].queryset = Member.objects.select_related('user')
class CommitteeMembershipInline(admin.StackedInline):
model = models.CommitteeMembership
form = CommitteeMembershipInlineForm
can_delete = False
ordering = ('since',)
extra = 0
......
Supports Markdown
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