Skip to content

Fix PostMedia admin slow load caused by full Post queryset in change view#349

Merged
animemoeus merged 2 commits intomasterfrom
copilot/fix-post-media-load-time
Mar 4, 2026
Merged

Fix PostMedia admin slow load caused by full Post queryset in change view#349
animemoeus merged 2 commits intomasterfrom
copilot/fix-post-media-load-time

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

The PostMediaAdmin change view was rendering the post FK as a standard <select>, forcing Django to load all Post records on every page open.

Change

  • Added autocomplete_fields = ["post"] to PostMediaAdmin — replaces the full dropdown with an AJAX autocomplete widget that only queries on user input
# instagram/admin/post_media.py
class PostMediaAdmin(ModelAdmin):
    autocomplete_fields = ["post"]  # added

PostAdmin already defines search_fields, satisfying Django's autocomplete prerequisite.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: animemoeus <33395829+animemoeus@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix slow loading of post media in admin Fix PostMedia admin slow load caused by full Post queryset in change view Mar 4, 2026
@animemoeus animemoeus marked this pull request as ready for review March 4, 2026 04:27
@animemoeus animemoeus merged commit 3e597cd into master Mar 4, 2026
2 checks passed
@animemoeus animemoeus deleted the copilot/fix-post-media-load-time branch March 4, 2026 04:31
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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