perf: autocomplete owner/configuration on Route admin change page#426
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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_fieldsforRouteAdmin.ownerandRouteAdmin.configuration. - Added
search_fieldstoRouteConfigAdminto satisfy Django’s autocomplete requirements for theconfigurationFK. - Added an admin test asserting both fields render as
AutocompleteSelectwidgets (handlingRelatedFieldWidgetWrapper).
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.
Contributor
Author
|
@victorlujanearthranger this is a follow-up PR, not urgent but useful when looking at Routes in the Django admin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #424. That PR fixed the dominant cause of the Route admin change-page timeout by adding
autocomplete_fieldsto the inlineintegrationFKs (an N+1 storm that scaled with the Integration table).The main change form still renders the
ownerandconfigurationForeignKeys as plain<select>dropdowns that eagerly load everyOrganization/RouteConfigurationrow. 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")(OrganizationAdminalready hassearch_fields).search_fields = ("id", "name")toRouteConfigAdminsoconfigurationqualifies for autocomplete.AutocompleteSelectwidget (unwrappingRelatedFieldWidgetWrapper).Verification
integrations/tests/test_admin.py— 2 passed (the existing fix: stop Route admin change page from timing out #424 scaling test plus the new widget test).manage.py checkpasses (validates theautocomplete_fields/search_fieldswiring).🤖 Generated with Claude Code