Skip to content

Move inlines to separate admin pages or make them read-only on Corpus admin

Refs https://redmine.teklia.com/issues/4746, ARKINDEX-BACKEND-1QE

When a corpus has large amounts of element types, memberships, or corpus exports, the inlines in its Django admin page will include too many fields in the form and trying to update the corpus raises a TooManyFieldsSent error. Additionally, all the inlines can cause dozens of duplicated queries: one per user or group in a membership, and one per export creator, slowing the page down significantly.

Avoiding inlines in the Django admin, or making them read-only, sounds like it could become a best practice, since it's a really easy way to get a N+1 problem as well as this error.

We already have a separate ModelAdmin for corpus exports, so that can be removed. Everything that the two membership inlines allow to do is already doable in the frontend, so that can be removed too.

All that remains is the element types inline, which is necessary to make types indexable. Corpus.indexable is editable in the API, which is probably a mistake, but ElementType.indexable is not, and both are necessary to index a corpus in Solr. We could make every attribute but indexable read-only in the ElementType inline, which should allow editing any corpus with up to 950 types or so, or create a new admin page for element types as well.