Skip to content

perf: autocomplete owner/configuration on Route admin change page#426

Merged
chrisdoehring merged 1 commit into
mainfrom
route-admin-autocomplete-owner-config
Jun 4, 2026
Merged

perf: autocomplete owner/configuration on Route admin change page#426
chrisdoehring merged 1 commit into
mainfrom
route-admin-autocomplete-owner-config

Conversation

@chrisdoehring
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #424. That PR fixed the dominant cause of the Route admin change-page timeout by adding autocomplete_fields to the inline integration FKs (an N+1 storm that scaled with the Integration table).

The main change form still renders the owner and configuration ForeignKeys as plain <select> dropdowns that eagerly load every Organization / RouteConfiguration row. These are single selects rendered once each — not the N+1 inline storm — but they still grow with those tables and add unnecessary weight to the page. This switches them to autocomplete for consistency and to keep the change page light as those tables grow.

Changes

  • RouteAdmin.autocomplete_fields = ("owner", "configuration") (OrganizationAdmin already has search_fields).
  • Added search_fields = ("id", "name") to RouteConfigAdmin so configuration qualifies for autocomplete.
  • Test asserting both fields render Django's AutocompleteSelect widget (unwrapping RelatedFieldWidgetWrapper).

Verification

🤖 Generated with Claude Code

Follow-up to #424, which fixed the dominant Route admin timeout by adding
autocomplete_fields to the inline integration FKs. The change form still
rendered the main-form `owner` and `configuration` FKs as plain dropdowns
that eagerly load every Organization / RouteConfiguration row. These are
single selects (not the N+1 inline storm), but they still grow with those
tables, so switch them to autocomplete too.

Adds search_fields to RouteConfigAdmin so `configuration` qualifies for
autocomplete, and a test asserting both fields render AutocompleteSelect.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up performance improvement to the Django admin Route change page. It reduces page weight by switching the owner and configuration ForeignKey widgets from eager-loading <select> dropdowns to Django admin’s AJAX-backed autocomplete widgets, keeping the change form responsive as Organization and RouteConfiguration tables grow.

Changes:

  • Enabled autocomplete_fields for RouteAdmin.owner and RouteAdmin.configuration.
  • Added search_fields to RouteConfigAdmin to satisfy Django’s autocomplete requirements for the configuration FK.
  • Added an admin test asserting both fields render as AutocompleteSelect widgets (handling RelatedFieldWidgetWrapper).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cdip_admin/integrations/admin.py Switches Route admin FK widgets to autocomplete and adds search_fields for RouteConfiguration to support it.
cdip_admin/integrations/tests/test_admin.py Adds coverage ensuring the Route change form uses autocomplete widgets for owner and configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chrisdoehring
Copy link
Copy Markdown
Contributor Author

@victorlujanearthranger this is a follow-up PR, not urgent but useful when looking at Routes in the Django admin.

@chrisdoehring chrisdoehring merged commit 067d8fc into main Jun 4, 2026
2 checks passed
@chrisdoehring chrisdoehring deleted the route-admin-autocomplete-owner-config branch June 4, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants