Opened 4 years ago
Closed 4 years ago
#31775 closed New feature (duplicate)
An option to enforce raw_id_fields in Admin site for all relation fields by default
Reported by: | DataGreed | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 3.0 |
Severity: | Normal | Keywords: | proposal |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
Context:
Currently Django Admin renders a select element (dropdown list) of all related foreign objects on django edit page.
Most of the time in the majority of application this causes major slowdowns and timeouts resulting in bad user experience.
To override this behaviour you have to specify ModelAdmin.raw_id_fields
manually so the all of the foreign objects won't be fetched and page will be loaded quickly. Since majority of applications only benefit from using raw_id_fields, developers need to write boilerplate code for every ModelAdmin with related keys.
Since just making raw id field widgets a default option may be a backward-incompatible change that may affect all of the users, I propose to add an setting that changes the default behaviour of this widget in admin site e.g. ADMIN_RAW_ID_FIELDS
which is set to False
by default. Setting this option to True
will render all foreign keys as raw_id_fields
by default saving a lot of time on writing boilerplate code on every migration involving Models with foreign keys that are rendered in Admin site.
This would be solved by an implementation for #17881.