admin.InlineModelAdmin.raw_id_fields

InlineModelAdmin.raw_id_fields

By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey. Sometimes you don’t want to incur the overhead of having to select all the related instances to display in the drop-down.

raw_id_fields is a list of fields you would like to change into an Input widget for either a ForeignKey or ManyToManyField:

1
2
3
class BookInline(admin.TabularInline):
    model = Book
    raw_id_fields = ("pages",)
doc_Django
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.