Sunday, January 31, 2021

Re: Show FK as input instead of drop down in admin

Another option if you want to show actual data, but only a portion, is to use an incremental lookup via an app such https://django-autocomplete-light.readthedocs.io/en/master/ - this works in the Admin as well.

On Saturday, 30 January 2021 at 20:58:00 UTC+2 Ryan Nowakowski wrote:
On Wed, Jan 27, 2021 at 05:33:10AM -0800, Kevin Olbrich wrote:
> Is it possible to disable fetching of related models for admin pages?
> I have a field that links to a table containing more than 1M rows which
> django tries to fetch and build the drop down. For my purpose, it is
> sufficient if it is a simple input containing the id instead.
>
> How can I accomplish this?

Yes, raw_id_fields is specifically designed for this:

https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8db9a0dd-336b-451c-85ac-f3fccbddf455n%40googlegroups.com.

No comments:

Post a Comment