Friday, February 2, 2018

Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

On 3/02/2018 5:23 AM, Paul Tiplady wrote:
> Currently it's simple to configure a filter on a foreign key in the
> admin:
>
> `list_filter = ['theforeignkeyfield']`
>
> However in practice this is barely usable in most cases that I've
> encountered, since the admin uses RelatedFieldListFilter, which
> fetches the full list of objects from the DB and loads them into the
> browser. For any production site that either times out or makes the
> admin unusably slow, not to mention the UX is terrible as it inserts a
> list of all of the items into the filter bar that needs to be scrolled
> through.
>
> I'm not sure if this is fixed in 2.0 (I haven't played with the new
> select2 integration that was added), but is there a plugin /
> workaround to use something like django-autocomplete-light, or a
> `raw_id_field` type approach in pre-2.0?

Have you looked at  ...

https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

M


> --
> 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
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4e610074-ff8c-494d-977e-cf701c8cd92f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4e610074-ff8c-494d-977e-cf701c8cd92f%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/89fd33b4-c8fb-09ac-1f0b-296f82463f55%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment