#25114 closed Cleanup/optimization (wontfix)
A way to change default raw_id_fields behavior — at Version 4
| Reported by: | damon c | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.8 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Foreign key fields in the admin currently default to a behavior that can cause crashes and user inconvenience.
The default behavior is to render a <select> element containing every instance of the model referred to by the FK.
When this field refers to a model that has for example, 100,000 or more entries, this can have the affect of crashing a server, a browser, or at best making new users confused about why they cannot view the admin page for this instance.
A get_raw_id_fields method that enables
Change History (4)
comment:1 by , 10 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 10 years ago
| Type: | Uncategorized → Cleanup/optimization |
|---|
comment:3 by , 10 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
comment:4 by , 10 years ago
| Description: | modified (diff) |
|---|---|
| Summary: | ModelAdmin FK fields should default to raw_id → A way to change default raw_id_fields behavior |
You are totally right about this. I was just here to propose an alternate solution to this but I will start a discussion on the dev mailing list.
something like this...
def get_raw_id_fields(self):
"""
Hook for overriding default raw_id_fields behavior
"""
return self.raw_id_fields
I don't think the justification is strong enough to warrant a backwards incompatible change here (i.e. every Django project would have to switch from opting-in to
raw_id_fieldsto opting-out), but feel free to open a discussion on the DevelopersMailingList if you want to try to get a consensus otherwise.