Friday, May 30, 2014

Re: Enumerating objects in foreign key in the admin

Hi Christophe,

The built-in way to handle this is to add a `raw_id_fields` declaration to your ModelAdmin or Inline definition. This will replace the pulldown select widget (populated with every possible value) with a single text input that stores the primary key of the related object, plus a popup that makes it easy (well… easier) to find the right PK.


Of course, a custom widget might give you a better UI, but if you're just looking to make it work and not drag the rendering of the admin UI page to a crawl, it works.

Yours,
Russ Magee %-)

On Sat, May 31, 2014 at 1:17 PM, Christophe Pettus <xof@thebuild.com> wrote:
Right now, when one has a foreign key field in a detail page in the admin, it appears to enumerate the objects (one at a time) in order to build the pop-up.  Obviously, if the other side of the foreign key relationship has a lot of entries, this can be a problem.  Short of doing a different, custom widget, is there a way to avoid this?
--
-- Christophe Pettus
   xof@thebuild.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/DBC6EF68-4DE3-432B-9237-D3973D80825F%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84-ZxjTnJD%2B0jVGkYstK%3DeHV-nbj0gXYOmkCE_%2B7VnHgeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment