Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25114 closed Cleanup/optimization (wontfix)

A way to change default raw_id_fields behavior

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 damon c)

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 (6)

comment:1 by damon c, 9 years ago

Description: modified (diff)

comment:2 by damon c, 9 years ago

Type: UncategorizedCleanup/optimization

comment:3 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

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_fields to opting-out), but feel free to open a discussion on the DevelopersMailingList if you want to try to get a consensus otherwise.

comment:4 by damon c, 9 years ago

Description: modified (diff)
Summary: ModelAdmin FK fields should default to raw_idA 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

comment:5 by Tim Graham, 9 years ago

There's an open ticket about adding get_raw_id_fields(): #17881.

comment:6 by damon c, 9 years ago

so sorry. I really did look for this!
Ok great!

Note: See TracTickets for help on using tickets.
Back to Top