Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Use some read only fields in the Django admin #527

Merged
merged 1 commit into from May 20, 2019

Conversation

jwalgran
Copy link
Contributor

@jwalgran jwalgran commented May 17, 2019

Overview

The Facility, FacilityListItem, and FacilityMatch admin were loading combo boxes with all possible related objects. With a database populated with 10s of thousands of records this would make admin page requests so slow that the ECS task would be terminated.

This commit fixes that by simply making the related fields read only. This works because we would not want to adjust these specific foreign key relationships anyway.

While making some fields read only we also took the opportunity to also make the JSON status fields read only and add a helper to render them in a more readable way.

Connects #526

Demo

Facility

Screen Shot 2019-05-17 at 1 18 25 PM

FacilityListItem

Screen Shot 2019-05-17 at 1 17 59 PM

FacilityMatch

Screen Shot 2019-05-17 at 1 18 40 PM

Notes

Optional. Ancillary topics, caveats, alternative strategies that didn't work out, anything else.

Testing Instructions

This test/ branch was tested on staging which has a stale copy of production data.

  • Log in as an admin and verify that you can successfully load Facility, FacilityListItem, and FacilityMatch detail pages.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

The Facility, FacilityListItem, and FacilityMatch admin were loading combo boxes
with all possible related objects. With a database populated with 10s of
thousands of records this would make admin page requests so slow that the ECS
task would be terminated.

This commit fixes that by simply making the related fields read only. This works
because we would not want to adjust these specific foreign key relationships
anyway.

While making some fields read only we also took the opportunity to also make the
JSON status fields read only and add a helper to render them in a more readable
way.
Copy link
Contributor

@kellyi kellyi left a comment

Choose a reason for hiding this comment

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

👍

Screen Shot 2019-05-20 at 10 55 52 AM
Screen Shot 2019-05-20 at 10 56 28 AM

@kellyi kellyi assigned jwalgran and unassigned kellyi May 20, 2019
@jwalgran
Copy link
Contributor Author

Thanks for the review.

@jwalgran jwalgran merged commit b84f655 into develop May 20, 2019
@jwalgran jwalgran deleted the test/readonly-admin-field branch May 20, 2019 15:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants